summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/java/checkstyle.vim15
-rw-r--r--test/handler/test_checkstyle_handler.vader13
2 files changed, 27 insertions, 1 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim
index 8155170a..7d0c31ba 100644
--- a/ale_linters/java/checkstyle.vim
+++ b/ale_linters/java/checkstyle.vim
@@ -2,9 +2,11 @@
" Description: checkstyle for Java files
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
- let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
let l:output = []
+ " modern checkstyle versions
+ let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'type': l:match[1] is? 'WARN' ? 'W' : 'E',
@@ -15,6 +17,17 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
\})
endfor
+ " old checkstyle versions
+ let l:pattern = '\v(.+):(\d+): ([^:]+): (.+)$'
+
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ call add(l:output, {
+ \ 'type': l:match[3] is? 'warning' ? 'W' : 'E',
+ \ 'lnum': l:match[2] + 0,
+ \ 'text': l:match[4],
+ \})
+ endfor
+
return l:output
endfunction
diff --git a/test/handler/test_checkstyle_handler.vader b/test/handler/test_checkstyle_handler.vader
index 2f1f0f8d..218fe344 100644
--- a/test/handler/test_checkstyle_handler.vader
+++ b/test/handler/test_checkstyle_handler.vader
@@ -26,3 +26,16 @@ Execute(The checkstyle handler should parse lines correctly):
\ '[WARN] whatever:101: ''method def rcurly'' has incorrect indentation level 4, expected level should be 2. [Indentation]',
\ '[WARN] whatever:63:3: Missing a Javadoc comment. [JavadocMethod]',
\ ])
+
+Execute(The checkstyle handler should parse lines from older checkstyle versions correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 289,
+ \ 'text': '''method def modifier'' have incorrect indentation level 4, expected level should be 2.',
+ \ 'type': 'W',
+ \ },
+ \ ],
+ \ ale_linters#java#checkstyle#Handle(666, [
+ \ '/home/languitar/src/rsb-java/rsb-java/src/main/java/rsb/Listener.java:289: warning: ''method def modifier'' have incorrect indentation level 4, expected level should be 2.',
+ \ ])