From b2fe1b2567a1a1e6a5e2ff805a46fa7f546ce62c Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 26 Feb 2017 14:51:22 +0000 Subject: [PATCH] Copy all loclist items returned from handlers, and set up defaults for convenience --- ale_linters/chef/foodcritic.vim | 2 - ale_linters/coffee/coffeelint.vim | 2 - ale_linters/cs/mcs.vim | 2 - ale_linters/d/dmd.vim | 2 - ale_linters/dockerfile/hadolint.vim | 1 - ale_linters/elixir/credo.vim | 2 - ale_linters/elm/make.vim | 2 - ale_linters/erlang/erlc.vim | 4 - ale_linters/fortran/gcc.vim | 2 - ale_linters/go/gobuild.vim | 2 - ale_linters/haskell/hlint.vim | 1 - ale_linters/html/tidy.vim | 2 - ale_linters/java/javac.vim | 2 - ale_linters/javascript/eslint.vim | 2 - ale_linters/javascript/flow.vim | 1 - ale_linters/javascript/standard.vim | 2 - ale_linters/json/jsonlint.vim | 2 - ale_linters/lua/luacheck.vim | 2 - ale_linters/markdown/mdl.vim | 2 - ale_linters/matlab/mlint.vim | 2 - ale_linters/perl/perl.vim | 2 - ale_linters/perl/perlcritic.vim | 2 - ale_linters/php/hack.vim | 1 - ale_linters/php/php.vim | 2 - ale_linters/php/phpcs.vim | 2 - ale_linters/php/phpmd.vim | 2 - ale_linters/puppet/puppet.vim | 2 - ale_linters/python/mypy.vim | 2 - ale_linters/ruby/rubocop.vim | 2 - ale_linters/scala/scalac.vim | 2 - ale_linters/scss/scsslint.vim | 2 - ale_linters/sh/shell.vim | 2 - ale_linters/sml/smlnj.vim | 2 - ale_linters/tex/chktex.vim | 2 - ale_linters/tex/lacheck.vim | 2 - ale_linters/typescript/tslint.vim | 2 - ale_linters/typescript/typecheck.vim | 2 - ale_linters/verilog/iverilog.vim | 2 - ale_linters/verilog/verilator.vim | 2 - ale_linters/yaml/yamllint.vim | 2 - autoload/ale/engine.vim | 43 +++++++-- doc/ale.txt | 20 +++++ test/test_credo_handler.vader | 4 - test/test_eslint_handler.vader | 6 -- test/test_flow_handler.vader | 2 - test/test_fortran_handler.vader | 12 --- test/test_loclist_corrections.vader | 130 +++++++++++++++++++++++++++ test/test_mypy_handler.vader | 4 - test/test_php_handler.vader | 10 --- test/test_standard_handler.vader | 6 -- test/test_typecheck_handler.vader | 4 - 51 files changed, 185 insertions(+), 134 deletions(-) create mode 100644 test/test_loclist_corrections.vader diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim index 0728a37..44ab568 100644 --- a/ale_linters/chef/foodcritic.vim +++ b/ale_linters/chef/foodcritic.vim @@ -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 diff --git a/ale_linters/coffee/coffeelint.vim b/ale_linters/coffee/coffeelint.vim index 8b1c713..a7960b9 100644 --- a/ale_linters/coffee/coffeelint.vim +++ b/ale_linters/coffee/coffeelint.vim @@ -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 diff --git a/ale_linters/cs/mcs.vim b/ale_linters/cs/mcs.vim index 3d39cfb..f1e1fc8 100644 --- a/ale_linters/cs/mcs.vim +++ b/ale_linters/cs/mcs.vim @@ -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 diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim index 26e8014..bf3d3d3 100644 --- a/ale_linters/d/dmd.vim +++ b/ale_linters/d/dmd.vim @@ -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 diff --git a/ale_linters/dockerfile/hadolint.vim b/ale_linters/dockerfile/hadolint.vim index dc8e642..f82cb8a 100644 --- a/ale_linters/dockerfile/hadolint.vim +++ b/ale_linters/dockerfile/hadolint.vim @@ -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, diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim index 6bf3835..8ce1242 100644 --- a/ale_linters/elixir/credo.vim +++ b/ale_linters/elixir/credo.vim @@ -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 diff --git a/ale_linters/elm/make.vim b/ale_linters/elm/make.vim index 714272c..2329783 100644 --- a/ale_linters/elm/make.vim +++ b/ale_linters/elm/make.vim @@ -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 diff --git a/ale_linters/erlang/erlc.vim b/ale_linters/erlang/erlc.vim index 571592f..8433d9a 100644 --- a/ale_linters/erlang/erlc.vim +++ b/ale_linters/erlang/erlc.vim @@ -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 diff --git a/ale_linters/fortran/gcc.vim b/ale_linters/fortran/gcc.vim index 8d15cc0..6d3f495 100644 --- a/ale_linters/fortran/gcc.vim +++ b/ale_linters/fortran/gcc.vim @@ -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. diff --git a/ale_linters/go/gobuild.vim b/ale_linters/go/gobuild.vim index 832669f..e6ca9f9 100644 --- a/ale_linters/go/gobuild.vim +++ b/ale_linters/go/gobuild.vim @@ -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 diff --git a/ale_linters/haskell/hlint.vim b/ale_linters/haskell/hlint.vim index 5b870e3..6a907ab 100644 --- a/ale_linters/haskell/hlint.vim +++ b/ale_linters/haskell/hlint.vim @@ -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', diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim index 5352034..de873c8 100644 --- a/ale_linters/html/tidy.vim +++ b/ale_linters/html/tidy.vim @@ -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 diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim index af2dbc9..5652d9d 100644 --- a/ale_linters/java/javac.vim +++ b/ale_linters/java/javac.vim @@ -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 diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim index c2794ec..baca3dd 100644 --- a/ale_linters/javascript/eslint.vim +++ b/ale_linters/javascript/eslint.vim @@ -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 diff --git a/ale_linters/javascript/flow.vim b/ale_linters/javascript/flow.vim index c1ee4b2..98bda75 100644 --- a/ale_linters/javascript/flow.vim +++ b/ale_linters/javascript/flow.vim @@ -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', diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim index 9dc2d20..1232b65 100644 --- a/ale_linters/javascript/standard.vim +++ b/ale_linters/javascript/standard.vim @@ -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 diff --git a/ale_linters/json/jsonlint.vim b/ale_linters/json/jsonlint.vim index 5af8f62..e1fb2bd 100644 --- a/ale_linters/json/jsonlint.vim +++ b/ale_linters/json/jsonlint.vim @@ -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 diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim index ace464c..c4c79b1 100644 --- a/ale_linters/lua/luacheck.vim +++ b/ale_linters/lua/luacheck.vim @@ -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 diff --git a/ale_linters/markdown/mdl.vim b/ale_linters/markdown/mdl.vim index c984252..7e64304 100644 --- a/ale_linters/markdown/mdl.vim +++ b/ale_linters/markdown/mdl.vim @@ -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 diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim index 8eb747e..563cf19 100644 --- a/ale_linters/matlab/mlint.vim +++ b/ale_linters/matlab/mlint.vim @@ -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 diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index 3724244..4a4ea50 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -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 diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim index dfad2d4..f146085 100644 --- a/ale_linters/perl/perlcritic.vim +++ b/ale_linters/perl/perlcritic.vim @@ -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 diff --git a/ale_linters/php/hack.vim b/ale_linters/php/hack.vim index 5c90247..762486b 100644 --- a/ale_linters/php/hack.vim +++ b/ale_linters/php/hack.vim @@ -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', diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim index d95e28a..aa5229c 100644 --- a/ale_linters/php/php.vim +++ b/ale_linters/php/php.vim @@ -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 diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim index 4b3cabd..2edd6ed 100644 --- a/ale_linters/php/phpcs.vim +++ b/ale_linters/php/phpcs.vim @@ -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 diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim index e7f87bc..e172a6a 100644 --- a/ale_linters/php/phpmd.vim +++ b/ale_linters/php/phpmd.vim @@ -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 diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim index 175d059..6561bf8 100644 --- a/ale_linters/puppet/puppet.vim +++ b/ale_linters/puppet/puppet.vim @@ -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 diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim index 55ab902..187bb83 100644 --- a/ale_linters/python/mypy.vim +++ b/ale_linters/python/mypy.vim @@ -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 diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim index 87fc7b7..7f6985d 100644 --- a/ale_linters/ruby/rubocop.vim +++ b/ale_linters/ruby/rubocop.vim @@ -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 diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim index 6f46206..6cd4d24 100644 --- a/ale_linters/scala/scalac.vim +++ b/ale_linters/scala/scalac.vim @@ -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 diff --git a/ale_linters/scss/scsslint.vim b/ale_linters/scss/scsslint.vim index 1ee0662..d8aeef0 100644 --- a/ale_linters/scss/scsslint.vim +++ b/ale_linters/scss/scsslint.vim @@ -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 diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim index 786cc0e..c7365ae 100644 --- a/ale_linters/sh/shell.vim +++ b/ale_linters/sh/shell.vim @@ -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 diff --git a/ale_linters/sml/smlnj.vim b/ale_linters/sml/smlnj.vim index 5e7f40a..c75f89b 100644 --- a/ale_linters/sml/smlnj.vim +++ b/ale_linters/sml/smlnj.vim @@ -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 diff --git a/ale_linters/tex/chktex.vim b/ale_linters/tex/chktex.vim index 2d53c66..95fd2ba 100644 --- a/ale_linters/tex/chktex.vim +++ b/ale_linters/tex/chktex.vim @@ -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 diff --git a/ale_linters/tex/lacheck.vim b/ale_linters/tex/lacheck.vim index 848cbed..94b79e6 100644 --- a/ale_linters/tex/lacheck.vim +++ b/ale_linters/tex/lacheck.vim @@ -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 diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim index ae41ed4..2f4d235 100644 --- a/ale_linters/typescript/tslint.vim +++ b/ale_linters/typescript/tslint.vim @@ -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 diff --git a/ale_linters/typescript/typecheck.vim b/ale_linters/typescript/typecheck.vim index 0de6639..c5ba05f 100644 --- a/ale_linters/typescript/typecheck.vim +++ b/ale_linters/typescript/typecheck.vim @@ -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 diff --git a/ale_linters/verilog/iverilog.vim b/ale_linters/verilog/iverilog.vim index cf1b0fa..0a118f3 100644 --- a/ale_linters/verilog/iverilog.vim +++ b/ale_linters/verilog/iverilog.vim @@ -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 diff --git a/ale_linters/verilog/verilator.vim b/ale_linters/verilog/verilator.vim index 4ff2093..b134438 100644 --- a/ale_linters/verilog/verilator.vim +++ b/ale_linters/verilog/verilator.vim @@ -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 diff --git a/ale_linters/yaml/yamllint.vim b/ale_linters/yaml/yamllint.vim index 42006fb..dcad70c 100644 --- a/ale_linters/yaml/yamllint.vim +++ b/ale_linters/yaml/yamllint.vim @@ -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 diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 61db4a1..bc83408 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -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 diff --git a/doc/ale.txt b/doc/ale.txt index 5f9cdea..b938ae0 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -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. diff --git a/test/test_credo_handler.vader b/test/test_credo_handler.vader index 1100ce1..73f98ba 100644 --- a/test/test_credo_handler.vader +++ b/test/test_credo_handler.vader @@ -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, [ diff --git a/test/test_eslint_handler.vader b/test/test_eslint_handler.vader index 57efa6b..692d8b3 100644 --- a/test/test_eslint_handler.vader +++ b/test/test_eslint_handler.vader @@ -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, [ diff --git a/test/test_flow_handler.vader b/test/test_flow_handler.vader index 12fe089..c6b8610 100644 --- a/test/test_flow_handler.vader +++ b/test/test_flow_handler.vader @@ -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:', diff --git a/test/test_fortran_handler.vader b/test/test_fortran_handler.vader index 7648ff6..acd83e3 100644 --- a/test/test_fortran_handler.vader +++ b/test/test_fortran_handler.vader @@ -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, [ diff --git a/test/test_loclist_corrections.vader b/test/test_loclist_corrections.vader new file mode 100644 index 0000000..281f678 --- /dev/null +++ b/test/test_loclist_corrections.vader @@ -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'}], + \ ) diff --git a/test/test_mypy_handler.vader b/test/test_mypy_handler.vader index f886501..e161f8a 100644 --- a/test/test_mypy_handler.vader +++ b/test/test_mypy_handler.vader @@ -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, [ diff --git a/test/test_php_handler.vader b/test/test_php_handler.vader index 14e4d60..c3d7607 100644 --- a/test/test_php_handler.vader +++ b/test/test_php_handler.vader @@ -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, [ diff --git a/test/test_standard_handler.vader b/test/test_standard_handler.vader index 1d1b71c..4a69c21 100644 --- a/test/test_standard_handler.vader +++ b/test/test_standard_handler.vader @@ -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, [ diff --git a/test/test_typecheck_handler.vader b/test/test_typecheck_handler.vader index 2f8a219..e42bcaf 100644 --- a/test/test_typecheck_handler.vader +++ b/test/test_typecheck_handler.vader @@ -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, [