#852 - Capture error codes for checkstyle
This commit is contained in:
parent
49ccfb1a00
commit
7455e2e97d
@ -2,27 +2,17 @@
|
|||||||
" Description: checkstyle for Java files
|
" Description: checkstyle for Java files
|
||||||
|
|
||||||
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
||||||
let l:patterns = [
|
let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
|
||||||
\ '\v\[(WARN|ERROR)\] .*:(\d+):(\d+): (.*)',
|
|
||||||
\ '\v\[(WARN|ERROR)\] .*:(\d+): (.*)',
|
|
||||||
\]
|
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
let l:args = {
|
call add(l:output, {
|
||||||
|
\ 'type': l:match[1] is? 'WARN' ? 'W' : 'E',
|
||||||
\ 'lnum': l:match[2] + 0,
|
\ 'lnum': l:match[2] + 0,
|
||||||
\ 'type': l:match[1] =~? 'WARN' ? 'W' : 'E'
|
\ 'col': l:match[3] + 0,
|
||||||
\ }
|
\ 'text': l:match[4],
|
||||||
|
\ 'code': l:match[5],
|
||||||
let l:col = l:match[3] + 0
|
\})
|
||||||
if l:col > 0
|
|
||||||
let l:args['col'] = l:col
|
|
||||||
let l:args['text'] = l:match[4]
|
|
||||||
else
|
|
||||||
let l:args['text'] = l:match[3]
|
|
||||||
endif
|
|
||||||
|
|
||||||
call add(l:output, l:args)
|
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
return l:output
|
return l:output
|
||||||
|
@ -9,17 +9,20 @@ Execute(The checkstyle handler should parse lines correctly):
|
|||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 101,
|
\ 'lnum': 101,
|
||||||
\ 'text': "'method def rcurly' has incorrect indentation level 4, expected level should be 2. [Indentation]",
|
\ 'col': 0,
|
||||||
|
\ 'text': '''method def rcurly'' has incorrect indentation level 4, expected level should be 2.',
|
||||||
|
\ 'code': 'Indentation',
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ },
|
\ },
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 63,
|
\ 'lnum': 63,
|
||||||
\ 'col': 3,
|
\ 'col': 3,
|
||||||
\ 'text': "Missing a Javadoc comment. [JavadocMethod]",
|
\ 'text': 'Missing a Javadoc comment.',
|
||||||
|
\ 'code': 'JavadocMethod',
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale_linters#java#checkstyle#Handle(666, [
|
\ ale_linters#java#checkstyle#Handle(666, [
|
||||||
\ "[WARN] whatever:101: 'method def rcurly' has incorrect indentation level 4, expected level should be 2. [Indentation]",
|
\ '[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]",
|
\ '[WARN] whatever:63:3: Missing a Javadoc comment. [JavadocMethod]',
|
||||||
\ ])
|
\ ])
|
||||||
|
Loading…
Reference in New Issue
Block a user