Copy all loclist items returned from handlers, and set up defaults for convenience

This commit is contained in:
w0rp 2017-02-26 14:51:22 +00:00
parent f1e80b800c
commit b2fe1b2567
51 changed files with 185 additions and 134 deletions

View File

@ -21,11 +21,9 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[3] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:text,
\ 'type': 'W',
\ 'nr': -1,
\})
endfor

View File

@ -40,11 +40,9 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -21,11 +21,9 @@ function! ale_linters#cs#mcs#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3] . ': ' . l:match[4],
\ 'type': l:match[3] =~# '^error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -72,11 +72,9 @@ function! ale_linters#d#dmd#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': bufnr('%'),
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
\ 'nr': -1,
\})
endfor

View File

@ -27,7 +27,6 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:lnum,
\ 'vcol': 0,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:text,

View File

@ -27,11 +27,9 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'type': l:type,
\ 'text': l:text,
\ 'nr': -1,
\})
endfor

View File

@ -22,11 +22,9 @@ function! ale_linters#elm#make#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:error.region.start.line,
\ 'vcol': 0,
\ 'col': l:error.region.start.column,
\ 'type': (l:error.type ==? 'error') ? 'E' : 'W',
\ 'text': l:error.overview,
\ 'nr': -1,
\})
endif
endfor

View File

@ -43,11 +43,9 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'type': 'E',
\ 'text': l:match_parse_transform[0],
\ 'nr': -1,
\})
continue
@ -77,11 +75,9 @@ function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': 0,
\ 'type': l:type,
\ 'text': l:text,
\ 'nr': -1,
\})
endfor

View File

@ -41,9 +41,7 @@ function! ale_linters#fortran#gcc#Handle(buffer, lines) abort
let l:last_loclist_obj = {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'nr': -1,
\}
" Start looking for the message and error type.

View File

@ -190,11 +190,9 @@ function! ale_linters#go#gobuild#Handler(buffer, lines) abort
call add(l:output, {
\ 'bufnr': l:buffer,
\ 'lnum': l:match[2] + 0,
\ 'vcol': 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[4],
\ 'type': 'E',
\ 'nr': -1,
\})
endfor

View File

@ -11,7 +11,6 @@ function! ale_linters#haskell#hlint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:error.startLine + 0,
\ 'vcol': 0,
\ 'col': l:error.startColumn + 0,
\ 'text': l:error.severity . ': ' . l:error.hint . '. Found: ' . l:error.from . ' Why not: ' . l:error.to,
\ 'type': l:error.severity ==# 'Error' ? 'E' : 'W',

View File

@ -53,11 +53,9 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -34,11 +34,9 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 1,
\ 'text': l:match[2] . ':' . l:match[3],
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -65,11 +65,9 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': l:type ==# 'Warning' ? 'W' : 'E',
\ 'nr': -1,
\})
endfor

View File

@ -68,7 +68,6 @@ function! ale_linters#javascript#flow#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': l:error.level ==# 'error' ? 'E' : 'W',

View File

@ -51,11 +51,9 @@ function! ale_linters#javascript#standard#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': 'E',
\ 'nr': -1,
\})
endfor

View File

@ -18,11 +18,9 @@ function! ale_linters#json#jsonlint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3],
\ 'type': 'E',
\ 'nr': -1,
\})
endfor

View File

@ -23,11 +23,9 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3],
\ 'nr': -1,
\})
endfor

View File

@ -16,11 +16,9 @@ function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\ 'nr': -1,
\})
endfor

View File

@ -44,11 +44,9 @@ function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:lnum,
\ 'vcol': 0,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': 'W',
\ 'nr': -1,
\})
endfor

View File

@ -21,11 +21,9 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -21,11 +21,9 @@ function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -19,7 +19,6 @@ function! ale_linters#php#hack#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[2] + 0,
\ 'vcol': 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[5],
\ 'type': 'E',

View File

@ -20,11 +20,9 @@ function! ale_linters#php#php#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[3] + 0,
\ 'vcol': 0,
\ 'col': empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1,
\ 'text': l:match[1],
\ 'type': 'E',
\ 'nr': -1,
\})
endfor

View File

@ -33,11 +33,9 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': l:type ==# 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -22,11 +22,9 @@ function! ale_linters#php#phpmd#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\ 'nr': -1,
\})
endfor

View File

@ -18,11 +18,9 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[2] + 0,
\ 'vcol': 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[1],
\ 'type': 'E',
\ 'nr': -1,
\})
endfor

View File

@ -44,11 +44,9 @@ function! g:ale_linters#python#mypy#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3] =~# 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -23,11 +23,9 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
\ 'type': index(['C', 'E'], l:type) != -1 ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -33,11 +33,9 @@ function! ale_linters#scala#scalac#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:col + 1,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -24,11 +24,9 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
\ 'type': l:match[3] ==# 'E' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -57,11 +57,9 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -23,11 +23,9 @@ function! ale_linters#sml#smlnj#Handle(buffer, lines) abort
call add(l:out, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 1,
\ 'text': l:match[2] . ': ' . l:match[3],
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -44,11 +44,9 @@ function! ale_linters#tex#chktex#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')',
\ 'type': 'W',
\ 'nr': -1
\})
endfor

View File

@ -38,11 +38,9 @@ function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\ 'nr': -1
\})
endfor

View File

@ -27,11 +27,9 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -26,11 +26,9 @@ function! ale_linters#typescript#typecheck#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:column,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -25,11 +25,9 @@ function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': 1,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endfor

View File

@ -39,11 +39,9 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': 1,
\ 'text': l:text,
\ 'type': l:type,
\ 'nr': -1,
\})
endif
endfor

View File

@ -39,11 +39,9 @@ function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'vcol': 0,
\ 'col': l:col,
\ 'text': l:text,
\ 'type': l:type ==# 'error' ? 'E' : 'W',
\ 'nr': -1,
\})
endfor

View File

@ -219,12 +219,9 @@ function! s:HandleExit(job) abort
let l:linter_loclist = ale#util#GetFunction(l:linter.callback)(l:buffer, l:output)
" Make some adjustments to the loclists to fix common problems.
call s:FixLocList(l:buffer, l:linter_loclist)
for l:item in l:linter_loclist
let l:item.linter_name = l:linter.name
endfor
" Make some adjustments to the loclists to fix common problems, and also
" to set default values for loclist items.
let l:linter_loclist = ale#engine#FixLocList(l:buffer, l:linter, l:linter_loclist)
" Add the loclist items from the linter.
call extend(g:ale_buffer_info[l:buffer].new_loclist, l:linter_loclist)
@ -303,20 +300,50 @@ function! s:HandleExitStatusVim(job, exit_code) abort
call s:SetExitCode(a:job, a:exit_code)
endfunction
function! s:FixLocList(buffer, loclist) abort
function! ale#engine#FixLocList(buffer, linter, loclist) abort
let l:new_loclist = []
" Some errors have line numbers beyond the end of the file,
" so we need to adjust them so they set the error at the last line
" of the file instead.
let l:last_line_number = ale#util#GetLineCount(a:buffer)
for l:item in a:loclist
for l:old_item in a:loclist
" Copy the loclist item with some default values and corrections.
"
" line and column numbers will be converted to numbers.
" The buffer will default to the buffer being checked.
" The vcol setting will default to 0, a byte index.
" The error type will default to 'E' for errors.
" The error number will default to -1.
"
" The line number and text are the only required keys.
"
" The linter_name will be set on the errors so it can be used in
" output, filtering, etc..
let l:item = {
\ 'text': l:old_item.text,
\ 'lnum': str2nr(l:old_item.lnum),
\ 'col': str2nr(get(l:old_item, 'col', 0)),
\ 'bufnr': get(l:old_item, 'bufnr', a:buffer),
\ 'vcol': get(l:old_item, 'vcol', 0),
\ 'type': get(l:old_item, 'type', 'E'),
\ 'nr': get(l:old_item, 'nr', -1),
\ 'linter_name': a:linter.name,
\}
if l:item.lnum == 0
" When errors appear at line 0, put them at line 1 instead.
let l:item.lnum = 1
elseif l:item.lnum > l:last_line_number
" When errors go beyond the end of the file, put them at the end.
let l:item.lnum = l:last_line_number
endif
call add(l:new_loclist, l:item)
endfor
return l:new_loclist
endfunction
" Given part of a command, replace any % with %%, so that no characters in

View File

@ -1219,6 +1219,26 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()*
This argument is required.
The keys for each item in the List will be handled in
the following manner:
`text` - This error message is required.
`lnum` - The line number is required. Any strings
will be automatically converted to numbers by
using `str2nr()`.
Line 0 will be moved to line 1, and lines beyond
the end of the file will be moved to the end.
`col` - The column number is optional and will
default to `0`. Any strings will be automatically
coverted to number using `str2nr()`.
`bufnr` - The buffer number should match the buffer
being checked, and this value will default to
the buffer being checked.
`vcol` - Defaults to `0`.
`type` - Defaults to `'E'`.
`nr` - Defaults to `-1`.
`executable` A |String| naming the executable itself which
will be run. This value will be used to check if the
program requested is installed or not.

View File

@ -6,20 +6,16 @@ Execute(The credo handler should parse lines correctly):
\ {
\ 'bufnr': 347,
\ 'lnum': 1,
\ 'vcol': 0,
\ 'col': 4,
\ 'text': 'There is no whitespace around parentheses/brackets most of the time, but here there is.',
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 26,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': 'If/else blocks should not have a negated condition in `if`.',
\ 'type': 'W',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#elixir#credo#Handle(347, [

View File

@ -6,29 +6,23 @@ Execute(The eslint handler should parse lines correctly):
\ {
\ 'bufnr': 347,
\ 'lnum': 47,
\ 'vcol': 0,
\ 'col': 14,
\ 'text': 'Missing trailing comma. [Warning/comma-dangle]',
\ 'type': 'W',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 56,
\ 'vcol': 0,
\ 'col': 41,
\ 'text': 'Missing semicolon. [Error/semi]',
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 13,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'Parsing error: Unexpected token',
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#javascript#eslint#Handle(347, [

View File

@ -114,7 +114,6 @@ Execute(The flow handler should process errors correctly.):
\ {
\ 'lnum': 417,
\ 'bufnr': 347,
\ 'vcol': 0,
\ 'type': 'E',
\ 'col': 10,
\ 'text': 'number: This type is incompatible with the expected return type of array type',
@ -122,7 +121,6 @@ Execute(The flow handler should process errors correctly.):
\ {
\ 'lnum': 419,
\ 'bufnr': 347,
\ 'vcol': 0,
\ 'type': 'W',
\ 'col': 3,
\ 'text': 'unreachable code:',

View File

@ -6,20 +6,16 @@ Execute(The fortran handler should parse lines from GCC 4.1.2 correctly):
\ {
\ 'bufnr': 357,
\ 'lnum': 4,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "Symbol b at (1) has no IMPLICIT type",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 357,
\ 'lnum': 3,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "Symbol a at (1) has no IMPLICIT type",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#fortran#gcc#Handle(357, [
@ -47,20 +43,16 @@ Execute(The fortran handler should parse lines from GCC 4.9.3 correctly):
\ {
\ 'bufnr': 357,
\ 'lnum': 3,
\ 'vcol': 0,
\ 'col': 12,
\ 'text': "Symbol a at (1) has no IMPLICIT type",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 357,
\ 'lnum': 4,
\ 'vcol': 0,
\ 'col': 12,
\ 'text': "Symbol b at (1) has no IMPLICIT type",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#fortran#gcc#Handle(357, [
@ -89,20 +81,16 @@ Execute(The fortran handler should parse lines from GCC 6.3.1 correctly):
\ {
\ 'bufnr': 337,
\ 'lnum': 3,
\ 'vcol': 0,
\ 'col': 12,
\ 'text': "Symbol a at (1) has no IMPLICIT type",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 337,
\ 'lnum': 4,
\ 'vcol': 0,
\ 'col': 12,
\ 'text': "Symbol b at (1) has no IMPLICIT type",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#fortran#gcc#Handle(337, [

View File

@ -0,0 +1,130 @@
Given foo (Some file with lines to count):
foo12345678
bar12345678
baz12345678
four12345678
five12345678
six12345678
seven12345678
eight12345678
nine12345678
ten12345678
Execute(FixLocList should set all the default values correctly):
AssertEqual
\ [
\ {
\ 'text': 'a',
\ 'lnum': 2,
\ 'col': 0,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'type': 'E',
\ 'nr': -1,
\ 'linter_name': 'foobar',
\ },
\ {
\ 'text': 'b',
\ 'lnum': 2,
\ 'col': 0,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'type': 'E',
\ 'nr': -1,
\ 'linter_name': 'foobar',
\ },
\],
\ ale#engine#FixLocList(
\ bufnr('%'),
\ {'name': 'foobar'},
\ [{'text': 'a', 'lnum': 2}, {'text': 'b', 'lnum': 2}],
\ )
Execute(FixLocList should use the values we supply):
AssertEqual
\ [
\ {
\ 'text': 'a',
\ 'lnum': 3,
\ 'col': 4,
\ 'bufnr': 10000,
\ 'vcol': 1,
\ 'type': 'W',
\ 'nr': 42,
\ 'linter_name': 'foobar',
\ },
\],
\ ale#engine#FixLocList(
\ bufnr('%'),
\ {'name': 'foobar'},
\ [{
\ 'text': 'a',
\ 'lnum': 3,
\ 'col': 4,
\ 'bufnr': 10000,
\ 'vcol': 1,
\ 'type': 'W',
\ 'nr': 42,
\ }],
\ )
Execute(FixLocList should set items with lines beyond the end to the last line):
AssertEqual
\ [
\ {
\ 'text': 'a',
\ 'lnum': 10,
\ 'col': 0,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'type': 'E',
\ 'nr': -1,
\ 'linter_name': 'foobar',
\ },
\],
\ ale#engine#FixLocList(
\ bufnr('%'),
\ {'name': 'foobar'},
\ [{'text': 'a', 'lnum': 11}],
\ )
Execute(FixLocList should move line 0 to line 1):
AssertEqual
\ [
\ {
\ 'text': 'a',
\ 'lnum': 1,
\ 'col': 0,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'type': 'E',
\ 'nr': -1,
\ 'linter_name': 'foobar',
\ },
\],
\ ale#engine#FixLocList(
\ bufnr('%'),
\ {'name': 'foobar'},
\ [{'text': 'a', 'lnum': 0}],
\ )
Execute(FixLocList should convert line and column numbers correctly):
" The numbers should be 10, not 8 as octals.
AssertEqual
\ [
\ {
\ 'text': 'a',
\ 'lnum': 10,
\ 'col': 10,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'type': 'E',
\ 'nr': -1,
\ 'linter_name': 'foobar',
\ },
\],
\ ale#engine#FixLocList(
\ bufnr('%'),
\ {'name': 'foobar'},
\ [{'text': 'a', 'lnum': '010', 'col': '010'}],
\ )

View File

@ -6,20 +6,16 @@ Execute(The mypy handler should parse lines correctly):
\ {
\ 'bufnr': 347,
\ 'lnum': 4,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "No library stub file for module 'django.db'",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 40,
\ 'vcol': 0,
\ 'col': 5,
\ 'text': "Some other problem",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#python#mypy#Handle(347, [

View File

@ -6,47 +6,37 @@ Execute(The php handler should parse lines correctly):
\ {
\ 'bufnr': 347,
\ 'lnum': 47,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "syntax error, unexpected ';', expecting ']'",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 56,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST)",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 13,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "syntax error, unexpected ')'",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 5,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "Invalid numeric literal",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 21,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': "syntax error, unexpected end of file",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#php#php#Handle(347, [

View File

@ -6,29 +6,23 @@ Execute(The standard handler should parse lines correctly):
\ {
\ 'bufnr': 347,
\ 'lnum': 47,
\ 'vcol': 0,
\ 'col': 14,
\ 'text': 'Expected indentation of 2 spaces but found 4.',
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 56,
\ 'vcol': 0,
\ 'col': 41,
\ 'text': 'Strings must use singlequote.',
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 13,
\ 'vcol': 0,
\ 'col': 3,
\ 'text': 'Parsing error: Unexpected token',
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#javascript#standard#Handle(347, [

View File

@ -6,20 +6,16 @@ Execute(The typecheck handler should parse lines correctly):
\ {
\ 'bufnr': 347,
\ 'lnum': 16,
\ 'vcol': 0,
\ 'col': 7,
\ 'text': "Type 'A' is not assignable to type 'B'",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ {
\ 'bufnr': 347,
\ 'lnum': 7,
\ 'vcol': 0,
\ 'col': 41,
\ 'text': "Property 'a' does not exist on type 'A'",
\ 'type': 'E',
\ 'nr': -1,
\ },
\ ],
\ ale_linters#typescript#typecheck#Handle(347, [