Adjust output of luacheck
linter to include error code (#717)
* linters/lua/luacheck: Show error code in message
This commit is contained in:
parent
b2e730fb5e
commit
2330837747
@ -22,14 +22,14 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort
|
||||
"
|
||||
" artal.lua:159:17: (W111) shadowing definition of loop variable 'i' on line 106
|
||||
" artal.lua:182:7: (W213) unused loop variable 'i'
|
||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\d\+) \(.\+\)$'
|
||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\(\d\+\)) \(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'text': l:match[3] . l:match[4] . ': ' . l:match[5],
|
||||
\ 'type': l:match[3],
|
||||
\})
|
||||
endfor
|
||||
|
32
test/handler/test_lua_handler.vader
Normal file
32
test/handler/test_lua_handler.vader
Normal file
@ -0,0 +1,32 @@
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The luacheck handler should parse lines correctly):
|
||||
runtime ale_linters/lua/luacheck.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 8,
|
||||
\ 'text': 'W612: line contains trailing whitespace',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 5,
|
||||
\ 'text': 'W213: unused loop variable ''k''',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 19,
|
||||
\ 'text': 'W113: accessing undefined variable ''x''',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#lua#luacheck#Handle(347, [
|
||||
\ ' /file/path/here.lua:1:8: (W612) line contains trailing whitespace',
|
||||
\ ' /file/path/here.lua:3:5: (W213) unused loop variable ''k''',
|
||||
\ ' /file/path/here.lua:3:19: (W113) accessing undefined variable ''x''',
|
||||
\ ])
|
Loading…
Reference in New Issue
Block a user