diff options
44 files changed, 263 insertions, 272 deletions
diff --git a/ale_linters/ansible/ansible-lint.vim b/ale_linters/ansible/ansible-lint.vim index f3bcf565..7f641b6c 100644 --- a/ale_linters/ansible/ansible-lint.vim +++ b/ale_linters/ansible/ansible-lint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('ansible', { \ 'name': 'ansible', \ 'executable': 'ansible', \ 'command': 'ansible-lint -p %t', -\ 'callback': 'ale#handlers#HandlePEP8Format', +\ 'callback': 'ale#handlers#python#HandlePEP8Format', \}) diff --git a/ale_linters/asciidoc/proselint.vim b/ale_linters/asciidoc/proselint.vim index 4851191e..b636c067 100644 --- a/ale_linters/asciidoc/proselint.vim +++ b/ale_linters/asciidoc/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('asciidoc', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/c/cppcheck.vim b/ale_linters/c/cppcheck.vim index e4e8eb0c..7da5b3ab 100644 --- a/ale_linters/c/cppcheck.vim +++ b/ale_linters/c/cppcheck.vim @@ -15,5 +15,5 @@ call ale#linter#Define('c', { \ 'output_stream': 'both', \ 'executable': 'cppcheck', \ 'command_callback': 'ale_linters#c#cppcheck#GetCommand', -\ 'callback': 'ale#handlers#HandleCppCheckFormat', +\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/ale_linters/cmake/cmakelint.vim b/ale_linters/cmake/cmakelint.vim index baf9e235..78676518 100644 --- a/ale_linters/cmake/cmakelint.vim +++ b/ale_linters/cmake/cmakelint.vim @@ -20,5 +20,5 @@ call ale#linter#Define('cmake', { \ 'name': 'cmakelint', \ 'executable_callback': 'ale_linters#cmake#cmakelint#Executable', \ 'command_callback': 'ale_linters#cmake#cmakelint#Command', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/cpp/cppcheck.vim b/ale_linters/cpp/cppcheck.vim index adb3f450..49cab0d9 100644 --- a/ale_linters/cpp/cppcheck.vim +++ b/ale_linters/cpp/cppcheck.vim @@ -15,5 +15,5 @@ call ale#linter#Define('cpp', { \ 'output_stream': 'both', \ 'executable': 'cppcheck', \ 'command_callback': 'ale_linters#cpp#cppcheck#GetCommand', -\ 'callback': 'ale#handlers#HandleCppCheckFormat', +\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat', \}) diff --git a/ale_linters/css/csslint.vim b/ale_linters/css/csslint.vim index 641e9c3e..fb262497 100644 --- a/ale_linters/css/csslint.vim +++ b/ale_linters/css/csslint.vim @@ -14,5 +14,5 @@ call ale#linter#Define('css', { \ 'name': 'csslint', \ 'executable': 'csslint', \ 'command_callback': 'ale_linters#css#csslint#GetCommand', -\ 'callback': 'ale#handlers#HandleCSSLintFormat', +\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/ale_linters/css/stylelint.vim b/ale_linters/css/stylelint.vim index 8c1c3be1..5cb67a81 100644 --- a/ale_linters/css/stylelint.vim +++ b/ale_linters/css/stylelint.vim @@ -31,5 +31,5 @@ call ale#linter#Define('css', { \ 'name': 'stylelint', \ 'executable_callback': 'ale_linters#css#stylelint#GetExecutable', \ 'command_callback': 'ale_linters#css#stylelint#GetCommand', -\ 'callback': 'ale#handlers#HandleStyleLintFormat', +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/ale_linters/go/gofmt.vim b/ale_linters/go/gofmt.vim index b38e4e98..337deef8 100644 --- a/ale_linters/go/gofmt.vim +++ b/ale_linters/go/gofmt.vim @@ -6,5 +6,5 @@ call ale#linter#Define('go', { \ 'output_stream': 'stderr', \ 'executable': 'gofmt', \ 'command': 'gofmt -e %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/go/golint.vim b/ale_linters/go/golint.vim index 8fe5b69b..cc807fe6 100644 --- a/ale_linters/go/golint.vim +++ b/ale_linters/go/golint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('go', { \ 'name': 'golint', \ 'executable': 'golint', \ 'command': 'golint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/go/gosimple.vim b/ale_linters/go/gosimple.vim index 09ea40b8..4b7d340b 100644 --- a/ale_linters/go/gosimple.vim +++ b/ale_linters/go/gosimple.vim @@ -5,5 +5,5 @@ call ale#linter#Define('go', { \ 'name': 'gosimple', \ 'executable': 'gosimple', \ 'command': 'gosimple %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/go/govet.vim b/ale_linters/go/govet.vim index e605a299..f5bb47a3 100644 --- a/ale_linters/go/govet.vim +++ b/ale_linters/go/govet.vim @@ -6,5 +6,5 @@ call ale#linter#Define('go', { \ 'output_stream': 'stderr', \ 'executable': 'go', \ 'command': 'go vet %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/go/staticcheck.vim b/ale_linters/go/staticcheck.vim index 711e2ce2..c78b3209 100644 --- a/ale_linters/go/staticcheck.vim +++ b/ale_linters/go/staticcheck.vim @@ -5,5 +5,5 @@ call ale#linter#Define('go', { \ 'name': 'staticcheck', \ 'executable': 'staticcheck', \ 'command': 'staticcheck %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/haskell/ghc.vim b/ale_linters/haskell/ghc.vim index 270f8ab1..ee6370b5 100644 --- a/ale_linters/haskell/ghc.vim +++ b/ale_linters/haskell/ghc.vim @@ -6,7 +6,7 @@ call ale#linter#Define('haskell', { \ 'output_stream': 'stderr', \ 'executable': 'ghc', \ 'command': 'ghc -fno-code -v0 %t', -\ 'callback': 'ale#handlers#HandleGhcFormat', +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) call ale#linter#Define('haskell', { @@ -14,5 +14,5 @@ call ale#linter#Define('haskell', { \ 'output_stream': 'stderr', \ 'executable': 'stack', \ 'command': 'stack ghc -- -fno-code -v0 %t', -\ 'callback': 'ale#handlers#HandleGhcFormat', +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/ale_linters/haskell/hdevtools.vim b/ale_linters/haskell/hdevtools.vim index 92bb8279..3e71ffbb 100644 --- a/ale_linters/haskell/hdevtools.vim +++ b/ale_linters/haskell/hdevtools.vim @@ -5,5 +5,5 @@ call ale#linter#Define('haskell', { \ 'name': 'hdevtools', \ 'executable': 'hdevtools', \ 'command': 'hdevtools check -g -Wall -p %s %t', -\ 'callback': 'ale#handlers#HandleGhcFormat', +\ 'callback': 'ale#handlers#haskell#HandleGHCFormat', \}) diff --git a/ale_linters/help/proselint.vim b/ale_linters/help/proselint.vim index cd6cb7f0..62124502 100644 --- a/ale_linters/help/proselint.vim +++ b/ale_linters/help/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('help', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/html/htmlhint.vim b/ale_linters/html/htmlhint.vim index 2edae372..ab1c6e02 100644 --- a/ale_linters/html/htmlhint.vim +++ b/ale_linters/html/htmlhint.vim @@ -28,5 +28,5 @@ call ale#linter#Define('html', { \ 'name': 'htmlhint', \ 'executable_callback': 'ale_linters#html#htmlhint#GetExecutable', \ 'command_callback': 'ale_linters#html#htmlhint#GetCommand', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/html/proselint.vim b/ale_linters/html/proselint.vim index 50ab5e49..9fd7d671 100644 --- a/ale_linters/html/proselint.vim +++ b/ale_linters/html/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('html', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/javascript/jscs.vim b/ale_linters/javascript/jscs.vim index 52710bac..aef607ec 100644 --- a/ale_linters/javascript/jscs.vim +++ b/ale_linters/javascript/jscs.vim @@ -5,5 +5,5 @@ call ale#linter#Define('javascript', { \ 'name': 'jscs', \ 'executable': 'jscs', \ 'command': 'jscs -r unix -n -', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/javascript/jshint.vim b/ale_linters/javascript/jshint.vim index 6835eeb0..ddb8619f 100644 --- a/ale_linters/javascript/jshint.vim +++ b/ale_linters/javascript/jshint.vim @@ -43,5 +43,5 @@ call ale#linter#Define('javascript', { \ 'name': 'jshint', \ 'executable_callback': 'ale_linters#javascript#jshint#GetExecutable', \ 'command_callback': 'ale_linters#javascript#jshint#GetCommand', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/markdown/proselint.vim b/ale_linters/markdown/proselint.vim index 295b1d02..289d8819 100644 --- a/ale_linters/markdown/proselint.vim +++ b/ale_linters/markdown/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('markdown', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/nroff/proselint.vim b/ale_linters/nroff/proselint.vim index ce5ff1e7..a23e56b1 100644 --- a/ale_linters/nroff/proselint.vim +++ b/ale_linters/nroff/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('nroff', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/pod/proselint.vim b/ale_linters/pod/proselint.vim index aa7c9406..2eb83f56 100644 --- a/ale_linters/pod/proselint.vim +++ b/ale_linters/pod/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('pod', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/pug/puglint.vim b/ale_linters/pug/puglint.vim index 4ded7ead..3f817c31 100644 --- a/ale_linters/pug/puglint.vim +++ b/ale_linters/pug/puglint.vim @@ -6,5 +6,5 @@ call ale#linter#Define('pug', { \ 'executable': 'pug-lint', \ 'output_stream': 'stderr', \ 'command': 'pug-lint -r inline %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/pyrex/cython.vim b/ale_linters/pyrex/cython.vim index 9168e092..bd5a447f 100644 --- a/ale_linters/pyrex/cython.vim +++ b/ale_linters/pyrex/cython.vim @@ -6,5 +6,5 @@ call ale#linter#Define('pyrex', { \ 'output_stream': 'stderr', \ 'executable': 'cython', \ 'command': 'cython --warning-extra -o ' . g:ale#util#nul_file . ' %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsError', +\ 'callback': 'ale#handlers#unix#HandleAsError', \}) diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index 71e04d21..a30dc03b 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -75,5 +75,5 @@ call ale#linter#Define('python', { \ {'callback': 'ale_linters#python#flake8#VersionCheck'}, \ {'callback': 'ale_linters#python#flake8#GetCommand'}, \ ], -\ 'callback': 'ale#handlers#HandlePEP8Format', +\ 'callback': 'ale#handlers#python#HandlePEP8Format', \}) diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index 37788f11..217fcc47 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -22,5 +22,5 @@ call ale#linter#Define('python', { \ 'name': 'pylint', \ 'executable_callback': 'ale_linters#python#pylint#GetExecutable', \ 'command_callback': 'ale_linters#python#pylint#GetCommand', -\ 'callback': 'ale#handlers#HandlePEP8Format', +\ 'callback': 'ale#handlers#python#HandlePEP8Format', \}) diff --git a/ale_linters/rst/proselint.vim b/ale_linters/rst/proselint.vim index 4e555dae..018347ae 100644 --- a/ale_linters/rst/proselint.vim +++ b/ale_linters/rst/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('rst', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/sass/sasslint.vim b/ale_linters/sass/sasslint.vim index 7d011907..bbe71255 100644 --- a/ale_linters/sass/sasslint.vim +++ b/ale_linters/sass/sasslint.vim @@ -4,5 +4,5 @@ call ale#linter#Define('sass', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', \ 'command': 'sass-lint -v -q -f compact %t', -\ 'callback': 'ale#handlers#HandleCSSLintFormat', +\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/ale_linters/sass/stylelint.vim b/ale_linters/sass/stylelint.vim index a148b879..14d5467e 100644 --- a/ale_linters/sass/stylelint.vim +++ b/ale_linters/sass/stylelint.vim @@ -27,5 +27,5 @@ call ale#linter#Define('sass', { \ 'name': 'stylelint', \ 'executable_callback': 'ale_linters#sass#stylelint#GetExecutable', \ 'command_callback': 'ale_linters#sass#stylelint#GetCommand', -\ 'callback': 'ale#handlers#HandleStyleLintFormat', +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/ale_linters/scss/sasslint.vim b/ale_linters/scss/sasslint.vim index ee4fdbb4..bd016465 100644 --- a/ale_linters/scss/sasslint.vim +++ b/ale_linters/scss/sasslint.vim @@ -4,5 +4,5 @@ call ale#linter#Define('scss', { \ 'name': 'sasslint', \ 'executable': 'sass-lint', \ 'command': 'sass-lint -v -q -f compact %t', -\ 'callback': 'ale#handlers#HandleCSSLintFormat', +\ 'callback': 'ale#handlers#css#HandleCSSLintFormat', \}) diff --git a/ale_linters/scss/stylelint.vim b/ale_linters/scss/stylelint.vim index edb4abb5..af462686 100644 --- a/ale_linters/scss/stylelint.vim +++ b/ale_linters/scss/stylelint.vim @@ -27,5 +27,5 @@ call ale#linter#Define('scss', { \ 'name': 'stylelint', \ 'executable_callback': 'ale_linters#scss#stylelint#GetExecutable', \ 'command_callback': 'ale_linters#scss#stylelint#GetCommand', -\ 'callback': 'ale#handlers#HandleStyleLintFormat', +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', \}) diff --git a/ale_linters/tex/proselint.vim b/ale_linters/tex/proselint.vim index b97fb3e4..35e764e2 100644 --- a/ale_linters/tex/proselint.vim +++ b/ale_linters/tex/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('tex', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/texinfo/proselint.vim b/ale_linters/texinfo/proselint.vim index 7b265144..003e3a0f 100644 --- a/ale_linters/texinfo/proselint.vim +++ b/ale_linters/texinfo/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('texinfo', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/text/proselint.vim b/ale_linters/text/proselint.vim index c1b81e95..281b4ffa 100644 --- a/ale_linters/text/proselint.vim +++ b/ale_linters/text/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('text', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/ale_linters/xhtml/proselint.vim b/ale_linters/xhtml/proselint.vim index 07f7a291..dfad921f 100644 --- a/ale_linters/xhtml/proselint.vim +++ b/ale_linters/xhtml/proselint.vim @@ -5,5 +5,5 @@ call ale#linter#Define('xhtml', { \ 'name': 'proselint', \ 'executable': 'proselint', \ 'command': 'proselint %t', -\ 'callback': 'ale#handlers#HandleUnixFormatAsWarning', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', \}) diff --git a/autoload/ale/handlers.vim b/autoload/ale/handlers.vim deleted file mode 100644 index 38c9fd42..00000000 --- a/autoload/ale/handlers.vim +++ /dev/null @@ -1,226 +0,0 @@ -scriptencoding utf-8 -" Author: w0rp <devw0rp@gmail.com> -" Description: This file defines some standard error format handlers. Any -" linter which outputs warnings and errors in a format accepted by one of -" these functions can simply use one of these pre-defined error handlers. - -let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+' - -function! s:HandleUnixFormat(buffer, lines, type) abort - " Matches patterns line the following: - " - " file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args - " file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary) - " file.go:5:2: expected declaration, found 'STRING' "log" - let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\d\+\)\?:\? \?\(.\+\)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:match[3], - \ 'type': a:type, - \}) - endfor - - return l:output -endfunction - -function! ale#handlers#HandleUnixFormatAsError(buffer, lines) abort - return s:HandleUnixFormat(a:buffer, a:lines, 'E') -endfunction - -function! ale#handlers#HandleUnixFormatAsWarning(buffer, lines) abort - return s:HandleUnixFormat(a:buffer, a:lines, 'W') -endfunction - -function! ale#handlers#HandleCppCheckFormat(buffer, lines) abort - " Look for lines like the following. - " - " [test.cpp:5]: (error) Array 'a[10]' accessed at index 10, which is out of bounds - let l:pattern = '^\[.\{-}:\(\d\+\)\]: (\(.\{-}\)) \(.\+\)' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': 0, - \ 'text': l:match[3] . ' (' . l:match[2] . ')', - \ 'type': l:match[2] ==# 'error' ? 'E' : 'W', - \}) - endfor - - return l:output -endfunction - -function! ale#handlers#HandlePEP8Format(buffer, lines) abort - " Matches patterns line the following: - " - " Matches patterns line the following: - " - " stdin:6:6: E111 indentation is not a multiple of four - " test.yml:35: [EANSIBLE0002] Trailing whitespace - let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\d\+\)\?: \[\?\(\([[:alpha:]]\)[[:alnum:]]\+\)\]\? \(.*\)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:code = l:match[3] - if (l:code ==# 'W291' || l:code ==# 'W293' || l:code ==# 'EANSIBLE002') - \ && !g:ale_warn_about_trailing_whitespace - " Skip warnings for trailing whitespace if the option is off. - continue - endif - - if l:code ==# 'I0011' - " Skip 'Locally disabling' message - continue - endif - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:code . ': ' . l:match[5], - \ 'type': l:match[4] ==# 'E' ? 'E' : 'W', - \}) - endfor - - return l:output -endfunction - -function! ale#handlers#HandleCSSLintFormat(buffer, lines) abort - " Matches patterns line the following: - " - " something.css: line 2, col 1, Error - Expected RBRACE at line 2, col 1. (errors) - " something.css: line 2, col 5, Warning - Expected (inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex) but found 'wat'. (known-properties) - " - " These errors can be very massive, so the type will be moved to the front - " so you can actually read the error type. - let l:pattern = '^.*: line \(\d\+\), col \(\d\+\), \(Error\|Warning\) - \(.\+\) (\([^)]\+\))$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:text = l:match[4] - let l:type = l:match[3] - let l:errorGroup = l:match[5] - - " Put the error group at the front, so we can see what kind of error - " it is on small echo lines. - let l:text = '(' . l:errorGroup . ') ' . l:text - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:text, - \ 'type': l:type ==# 'Warning' ? 'W' : 'E', - \}) - endfor - - return l:output -endfunction - -function! ale#handlers#HandleStyleLintFormat(buffer, lines) abort - " Matches patterns line the following: - " - " src/main.css - " 108:10 ✖ Unexpected leading zero number-leading-zero - " 116:20 ✖ Expected a trailing semicolon declaration-block-trailing-semicolon - let l:pattern = '^.* \(\d\+\):\(\d\+\) \s\+\(\S\+\)\s\+ \(\u.\+\) \(.\+\)$' - let l:output = [] - - for l:line in a:lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:type = l:match[3] ==# '✖' ? 'E' : 'W' - let l:text = l:match[4] . '[' . l:match[5] . ']' - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:text, - \ 'type': l:type, - \}) - endfor - - return l:output -endfunction - -function! ale#handlers#HandleGhcFormat(buffer, lines) abort - " Look for lines like the following. - " - "Appoint/Lib.hs:8:1: warning: - "Appoint/Lib.hs:8:1: - let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\(.*\)\?$' - let l:output = [] - - let l:corrected_lines = [] - for l:line in a:lines - if len(matchlist(l:line, l:pattern)) > 0 - call add(l:corrected_lines, l:line) - elseif l:line ==# '' - call add(l:corrected_lines, l:line) - else - if len(l:corrected_lines) > 0 - let l:line = substitute(l:line, '\v^\s+', ' ', '') - let l:corrected_lines[-1] .= l:line - endif - endif - endfor - - for l:line in l:corrected_lines - let l:match = matchlist(l:line, l:pattern) - - if len(l:match) == 0 - continue - endif - - let l:errors = matchlist(l:match[3], '\(warning:\|error:\)\(.*\)') - - if len(l:errors) > 0 - let l:type = l:errors[1] - let l:text = l:errors[2] - else - let l:type = '' - let l:text = l:match[3] - endif - - let l:type = l:type ==# '' ? 'E' : toupper(l:type[0]) - - call add(l:output, { - \ 'lnum': l:match[1] + 0, - \ 'col': l:match[2] + 0, - \ 'text': l:text, - \ 'type': l:type, - \}) - endfor - - return l:output -endfunction diff --git a/autoload/ale/handlers/cppcheck.vim b/autoload/ale/handlers/cppcheck.vim new file mode 100644 index 00000000..f5df58b7 --- /dev/null +++ b/autoload/ale/handlers/cppcheck.vim @@ -0,0 +1,20 @@ +" Description: Handle errors for cppcheck. + +function! ale#handlers#cppcheck#HandleCppCheckFormat(buffer, lines) abort + " Look for lines like the following. + " + " [test.cpp:5]: (error) Array 'a[10]' accessed at index 10, which is out of bounds + let l:pattern = '^\[.\{-}:\(\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': 0, + \ 'text': l:match[3] . ' (' . l:match[2] . ')', + \ 'type': l:match[2] ==# 'error' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction diff --git a/autoload/ale/handlers/css.vim b/autoload/ale/handlers/css.vim new file mode 100644 index 00000000..37ee5eea --- /dev/null +++ b/autoload/ale/handlers/css.vim @@ -0,0 +1,55 @@ +scriptencoding utf-8 +" Author: w0rp <devw0rp@gmail.com> +" Description: Error handling for CSS linters. + +function! ale#handlers#css#HandleCSSLintFormat(buffer, lines) abort + " Matches patterns line the following: + " + " something.css: line 2, col 1, Error - Expected RBRACE at line 2, col 1. (errors) + " something.css: line 2, col 5, Warning - Expected (inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex) but found 'wat'. (known-properties) + " + " These errors can be very massive, so the type will be moved to the front + " so you can actually read the error type. + let l:pattern = '^.*: line \(\d\+\), col \(\d\+\), \(Error\|Warning\) - \(.\+\) (\([^)]\+\))$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:text = l:match[4] + let l:type = l:match[3] + let l:errorGroup = l:match[5] + + " Put the error group at the front, so we can see what kind of error + " it is on small echo lines. + let l:text = '(' . l:errorGroup . ') ' . l:text + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:text, + \ 'type': l:type ==# 'Warning' ? 'W' : 'E', + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#css#HandleStyleLintFormat(buffer, lines) abort + " Matches patterns line the following: + " + " src/main.css + " 108:10 ✖ Unexpected leading zero number-leading-zero + " 116:20 ✖ Expected a trailing semicolon declaration-block-trailing-semicolon + let l:pattern = '\v^.* (\d+):(\d+) \s+(\S+)\s+ (.*[^ ])\s+([^ ]+)$' + 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, + \ 'type': l:match[3] ==# '✖' ? 'E' : 'W', + \ 'text': l:match[4] . ' [' . l:match[5] . ']', + \}) + endfor + + return l:output +endfunction diff --git a/autoload/ale/handlers/haskell.vim b/autoload/ale/handlers/haskell.vim new file mode 100644 index 00000000..cfddbdbf --- /dev/null +++ b/autoload/ale/handlers/haskell.vim @@ -0,0 +1,54 @@ +" Author: w0rp <devw0rp@gmail.com> +" Description: Error handling for the format GHC outputs. + +function! ale#handlers#haskell#HandleGHCFormat(buffer, lines) abort + " Look for lines like the following. + " + "Appoint/Lib.hs:8:1: warning: + "Appoint/Lib.hs:8:1: + let l:pattern = '^[^:]\+:\(\d\+\):\(\d\+\):\(.*\)\?$' + let l:output = [] + + let l:corrected_lines = [] + for l:line in a:lines + if len(matchlist(l:line, l:pattern)) > 0 + call add(l:corrected_lines, l:line) + elseif l:line ==# '' + call add(l:corrected_lines, l:line) + else + if len(l:corrected_lines) > 0 + let l:line = substitute(l:line, '\v^\s+', ' ', '') + let l:corrected_lines[-1] .= l:line + endif + endif + endfor + + for l:line in l:corrected_lines + let l:match = matchlist(l:line, l:pattern) + + if len(l:match) == 0 + continue + endif + + let l:errors = matchlist(l:match[3], '\(warning:\|error:\)\(.*\)') + + if len(l:errors) > 0 + let l:type = l:errors[1] + let l:text = l:errors[2] + else + let l:type = '' + let l:text = l:match[3] + endif + + let l:type = l:type ==# '' ? 'E' : toupper(l:type[0]) + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:text, + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction diff --git a/autoload/ale/handlers/python.vim b/autoload/ale/handlers/python.vim new file mode 100644 index 00000000..4777dd18 --- /dev/null +++ b/autoload/ale/handlers/python.vim @@ -0,0 +1,39 @@ +" Author: w0rp <devw0rp@gmail.com> +" Description: Error handling for flake8, etc. + +let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+' + +function! ale#handlers#python#HandlePEP8Format(buffer, lines) abort + " Matches patterns line the following: + " + " Matches patterns line the following: + " + " stdin:6:6: E111 indentation is not a multiple of four + " test.yml:35: [EANSIBLE0002] Trailing whitespace + let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\d\+\)\?: \[\?\(\([[:alpha:]]\)[[:alnum:]]\+\)\]\? \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:code = l:match[3] + + if (l:code ==# 'W291' || l:code ==# 'W293' || l:code ==# 'EANSIBLE002') + \ && !g:ale_warn_about_trailing_whitespace + " Skip warnings for trailing whitespace if the option is off. + continue + endif + + if l:code ==# 'I0011' + " Skip 'Locally disabling' message + continue + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:code . ': ' . l:match[5], + \ 'type': l:match[4] ==# 'E' ? 'E' : 'W', + \}) + endfor + + return l:output +endfunction diff --git a/autoload/ale/handlers/unix.vim b/autoload/ale/handlers/unix.vim new file mode 100644 index 00000000..be0f0823 --- /dev/null +++ b/autoload/ale/handlers/unix.vim @@ -0,0 +1,28 @@ +" Author: w0rp <devw0rp@gmail.com> +" Description: Error handling for errors in a Unix format. + +let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+' + +function! s:HandleUnixFormat(buffer, lines, type) abort + let l:pattern = '^' . s:path_pattern . ':\(\d\+\):\?\(\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[3], + \ 'type': a:type, + \}) + endfor + + return l:output +endfunction + +function! ale#handlers#unix#HandleAsError(buffer, lines) abort + return s:HandleUnixFormat(a:buffer, a:lines, 'E') +endfunction + +function! ale#handlers#unix#HandleAsWarning(buffer, lines) abort + return s:HandleUnixFormat(a:buffer, a:lines, 'W') +endfunction diff --git a/test/handler/test_common_handlers.vader b/test/handler/test_common_handlers.vader index 13bae8c4..345d7f40 100644 --- a/test/handler/test_common_handlers.vader +++ b/test/handler/test_common_handlers.vader @@ -14,7 +14,7 @@ Execute(HandleCSSLintFormat should handle CSS errors): \ 'text': "(known-properties) Expected ... but found 'wat'.", \ }, \ ], - \ ale#handlers#HandleCSSLintFormat(42, [ + \ ale#handlers#css#HandleCSSLintFormat(42, [ \ 'something.css: line 2, col 1, Error - Expected RBRACE at line 2, col 1. (errors)', \ "something.css: line 2, col 5, Warning - Expected ... but found 'wat'. (known-properties)", \ ]) @@ -35,7 +35,7 @@ Execute (HandlePEP8Format should handle the correct lines of output): \ 'text': "EANSIBLE0002: Trailing whitespace", \ }, \ ], - \ ale#handlers#HandlePEP8Format(42, [ + \ ale#handlers#python#HandlePEP8Format(42, [ \ "stdin:6:6: E111 indentation is not a multiple of four", \ "test.yml:35: [EANSIBLE0002] Trailing whitespace", \ ]) @@ -83,7 +83,7 @@ Execute (HandleUnixFormatAsError should handle some example lines of output): \ 'text': '".b" is not a valid class name. Class names must begin with "-", "_" or a letter and can only contain "_", "-", a-z and 0-9.', \ }, \ ], - \ ale#handlers#HandleUnixFormatAsError(42, [ + \ ale#handlers#unix#HandleAsError(42, [ \ 'file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args', \ 'file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)', \ 'test.pug:1:1 ".b" is not a valid class name. Class names must begin with "-", "_" or a letter and can only contain "_", "-", a-z and 0-9.', @@ -105,7 +105,7 @@ Execute (HandleUnixFormatAsError should handle lines with no space after the col \ 'text': 'bar', \ }, \ ], - \ ale#handlers#HandleUnixFormatAsError(42, [ + \ ale#handlers#unix#HandleAsError(42, [ \ 'some_file.xyz:27:foo', \ 'some_file.xyz:53:10:bar', \ ]) @@ -126,7 +126,7 @@ Execute (HandleUnixFormatAsWarning should handle some example lines of output): \ 'text': 'if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)', \ }, \ ], - \ ale#handlers#HandleUnixFormatAsWarning(42, [ + \ ale#handlers#unix#HandleAsWarning(42, [ \ 'file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args', \ 'file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)', \ ]) @@ -147,7 +147,7 @@ Execute (Unix format functions should handle Windows paths): \ 'text': 'foo', \ }, \ ], - \ ale#handlers#HandleUnixFormatAsError(42, [ + \ ale#handlers#unix#HandleAsError(42, [ \ 'C:\Users\w0rp\AppData\Local\Temp\Xyz123.go:27: foo', \ 'C:\Users\w0rp\AppData\Local\Temp\Xyz123.go:53:10: foo', \ ]) @@ -168,7 +168,7 @@ Execute (HandleCppCheckFormat should handle some example lines of output): \ 'text': 'Array a[10] accessed at index 10, which is out of bounds. (error)', \ }, \ ], - \ ale#handlers#HandleCppCheckFormat(42, [ + \ ale#handlers#cppcheck#HandleCppCheckFormat(42, [ \ '[/tmp/test.c:5]: (style) Variable a is assigned a value that is never used.', \ '[/tmp/test.c:12]: (error) Array a[10] accessed at index 10, which is out of bounds.' \ ]) diff --git a/test/handler/test_ghc_handler.vader b/test/handler/test_ghc_handler.vader index b9249744..e8d622bb 100644 --- a/test/handler/test_ghc_handler.vader +++ b/test/handler/test_ghc_handler.vader @@ -8,7 +8,7 @@ Execute(The ghc handler should handle hdevtools output): \ 'text': '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’ Expected type: [T.Text]', \ }, \ ], - \ ale#handlers#HandleGhcFormat(12, [ + \ ale#handlers#haskell#HandleGHCFormat(12, [ \ '/path/to/foo.hs:147:62: warning:', \ '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’', \ ' Expected type: [T.Text]', @@ -30,7 +30,7 @@ Execute(The ghc handler should handle ghc 8 output): \ 'text': ' Failed to load interface for ‘GitHub.Endpoints.PullRequests’ Use -v to see a list of the files searched for.', \ }, \ ], - \ ale#handlers#HandleGhcFormat(47, [ + \ ale#handlers#haskell#HandleGHCFormat(47, [ \ '', \ 'src/Appoint/Lib.hs:6:1: error:', \ ' Failed to load interface for ‘GitHub.Data’', @@ -51,7 +51,7 @@ Execute(The ghc handler should handle ghc 7 output): \ 'text': ' parse error (possibly incorrect indentation or mismatched brackets)', \ }, \ ], - \ ale#handlers#HandleGhcFormat(47, [ + \ ale#handlers#haskell#HandleGHCFormat(47, [ \ 'src/Main.hs:168:1:', \ ' parse error (possibly incorrect indentation or mismatched brackets)', \ ]) diff --git a/test/handler/test_stylelint_handler.vader b/test/handler/test_stylelint_handler.vader new file mode 100644 index 00000000..da2df534 --- /dev/null +++ b/test/handler/test_stylelint_handler.vader @@ -0,0 +1,21 @@ +Execute (stylelint errors should be handled correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 108, + \ 'col': 10, + \ 'type': 'E', + \ 'text': 'Unexpected leading zero [number-leading-zero]', + \ }, + \ { + \ 'lnum': 116, + \ 'col': 20, + \ 'type': 'E', + \ 'text': 'Expected a trailing semicolon [declaration-block-trailing-semicolon]', + \ }, + \ ], + \ ale#handlers#css#HandleStyleLintFormat(42, [ + \ 'src/main.css', + \ ' 108:10 ✖ Unexpected leading zero number-leading-zero', + \ ' 116:20 ✖ Expected a trailing semicolon declaration-block-trailing-semicolon', + \ ]) |