summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-04-18 00:35:53 +0100
committerw0rp <devw0rp@gmail.com>2017-04-18 00:35:53 +0100
commitbdad25eefd6526f8130f97edbe25a1179e27aadc (patch)
treec2e563e959121e77f6d96a256583849f6851f0a4
parente237add9fdec64c80ed57f383e2b73464fb4b43d (diff)
downloadale-bdad25eefd6526f8130f97edbe25a1179e27aadc.zip
Add a function for getting matches, and use it to simplify a lot of code
-rw-r--r--ale_linters/asm/gcc.vim14
-rw-r--r--ale_linters/chef/foodcritic.vim10
-rw-r--r--ale_linters/coffee/coffeelint.vim19
-rw-r--r--ale_linters/cs/mcs.vim9
-rw-r--r--ale_linters/d/dmd.vim22
-rw-r--r--ale_linters/dockerfile/hadolint.vim8
-rw-r--r--ale_linters/elixir/credo.vim8
-rw-r--r--ale_linters/elixir/dogma.vim8
-rw-r--r--ale_linters/haml/hamllint.vim9
-rw-r--r--ale_linters/html/tidy.vim9
-rw-r--r--ale_linters/java/javac.vim9
-rw-r--r--ale_linters/javascript/eslint.vim13
-rw-r--r--ale_linters/javascript/standard.vim8
-rw-r--r--ale_linters/json/jsonlint.vim10
-rw-r--r--ale_linters/lua/luacheck.vim9
-rw-r--r--ale_linters/markdown/mdl.vim10
-rw-r--r--ale_linters/matlab/mlint.vim8
-rw-r--r--ale_linters/nim/nimcheck.vim8
-rw-r--r--ale_linters/nix/nix.vim9
-rw-r--r--ale_linters/perl/perl.vim9
-rw-r--r--ale_linters/perl/perlcritic.vim18
-rw-r--r--ale_linters/php/hack.vim12
-rw-r--r--ale_linters/php/php.vim10
-rw-r--r--ale_linters/php/phpcs.vim9
-rw-r--r--ale_linters/php/phpmd.vim10
-rw-r--r--ale_linters/puppet/puppet.vim10
-rw-r--r--ale_linters/python/mypy.vim9
-rw-r--r--ale_linters/ruby/rubocop.vim9
-rw-r--r--ale_linters/ruby/ruby.vim1
-rw-r--r--ale_linters/scala/scalac.vim1
-rw-r--r--ale_linters/scss/scsslint.vim9
-rw-r--r--ale_linters/sh/shell.vim18
-rw-r--r--ale_linters/slim/slimlint.vim9
-rw-r--r--ale_linters/sql/sqlint.vim8
-rw-r--r--ale_linters/tex/chktex.vim9
-rw-r--r--ale_linters/tex/lacheck.vim10
-rw-r--r--ale_linters/typescript/tslint.vim11
-rw-r--r--ale_linters/typescript/typecheck.vim11
-rw-r--r--ale_linters/verilog/iverilog.vim9
-rw-r--r--ale_linters/verilog/verilator.vim9
-rw-r--r--ale_linters/yaml/yamllint.vim9
-rw-r--r--autoload/ale/util.vim24
-rw-r--r--test/handler/test_asm_handler.vader8
-rw-r--r--test/handler/test_coffeelint_handler.vader1
-rw-r--r--test/handler/test_mypy_handler.vader2
-rw-r--r--test/handler/test_nix_handler.vader2
-rw-r--r--test/handler/test_php_handler.vader14
-rw-r--r--test/handler/test_rubocop_handler.vader4
-rw-r--r--test/handler/test_ruby_handler.vader3
-rw-r--r--test/handler/test_shell_handler.vader12
-rw-r--r--test/handler/test_slim_handler.vader3
-rw-r--r--test/handler/test_typecheck_handler.vader4
-rw-r--r--test/test_getmatches.vader148
53 files changed, 224 insertions, 411 deletions
diff --git a/ale_linters/asm/gcc.vim b/ale_linters/asm/gcc.vim
index c25d4aec..4288f5de 100644
--- a/ale_linters/asm/gcc.vim
+++ b/ale_linters/asm/gcc.vim
@@ -13,21 +13,11 @@ function! ale_linters#asm#gcc#Handle(buffer, lines) abort
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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
- \ 'vcol': 0,
- \ 'col': 0,
- \ 'text': l:match[3],
\ 'type': l:match[2] =~? 'error' ? 'E' : 'W',
- \ 'nr': -1,
+ \ 'text': l:match[3],
\})
endfor
diff --git a/ale_linters/chef/foodcritic.vim b/ale_linters/chef/foodcritic.vim
index 8fa2dfe9..079e3041 100644
--- a/ale_linters/chef/foodcritic.vim
+++ b/ale_linters/chef/foodcritic.vim
@@ -13,19 +13,11 @@ function! ale_linters#chef#foodcritic#Handle(buffer, lines) abort
let l:pattern = '^\(.\+:\s.\+\):\s\(.\+\):\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:text = l:match[1]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[3] + 0,
- \ 'col': 0,
\ 'text': l:text,
\ 'type': 'W',
\})
diff --git a/ale_linters/coffee/coffeelint.vim b/ale_linters/coffee/coffeelint.vim
index bac86821..9db3399c 100644
--- a/ale_linters/coffee/coffeelint.vim
+++ b/ale_linters/coffee/coffeelint.vim
@@ -24,22 +24,11 @@ function! ale_linters#coffee#coffeelint#Handle(buffer, lines) abort
let l:pattern = 'stdin,\(\d\+\),\(\d*\),\(.\{-1,}\),\(.\+\)'
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:line = l:match[1] + 0
- let l:type = l:match[3] ==# 'error' ? 'E' : 'W'
- let l:text = l:match[4]
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
- \ 'lnum': l:line,
- \ 'text': l:text,
- \ 'type': l:type,
+ \ 'lnum': str2nr(l:match[1]),
+ \ 'type': l:match[3] ==# 'error' ? 'E' : 'W',
+ \ 'text': l:match[4],
\})
endfor
diff --git a/ale_linters/cs/mcs.vim b/ale_linters/cs/mcs.vim
index 690fec79..3d042f99 100644
--- a/ale_linters/cs/mcs.vim
+++ b/ale_linters/cs/mcs.vim
@@ -11,15 +11,8 @@ function! ale_linters#cs#mcs#Handle(buffer, lines) abort
let l:pattern = '^.\+.cs(\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3] . ': ' . l:match[4],
diff --git a/ale_linters/d/dmd.vim b/ale_linters/d/dmd.vim
index c6f8f209..3805e024 100644
--- a/ale_linters/d/dmd.vim
+++ b/ale_linters/d/dmd.vim
@@ -56,24 +56,12 @@ function! ale_linters#d#dmd#Handle(buffer, lines) abort
let l:pattern = '^[^(]\+(\([0-9]\+\)\,\?\([0-9]*\)): \([^:]\+\): \(.\+\)'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- break
- endif
-
- let l:line = l:match[1] + 0
- let l:column = l:match[2] + 0
- let l:type = l:match[3]
- let l:text = l:match[4]
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': bufnr('%'),
- \ 'lnum': l:line,
- \ 'col': l:column,
- \ 'text': l:text,
- \ 'type': l:type ==# 'Warning' ? 'W' : 'E',
+ \ 'lnum': l:match[1],
+ \ 'col': l:match[2],
+ \ 'type': l:match[3] ==# 'Warning' ? 'W' : 'E',
+ \ 'text': l:match[4],
\})
endfor
diff --git a/ale_linters/dockerfile/hadolint.vim b/ale_linters/dockerfile/hadolint.vim
index df1ac799..ab96d3cf 100644
--- a/ale_linters/dockerfile/hadolint.vim
+++ b/ale_linters/dockerfile/hadolint.vim
@@ -7,13 +7,7 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
let l:pattern = '\v^/dev/stdin:?(\d+)? (\S+) (.+)$'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:lnum = 0
if l:match[1] !=# ''
diff --git a/ale_linters/elixir/credo.vim b/ale_linters/elixir/credo.vim
index ce34f47c..46f75457 100644
--- a/ale_linters/elixir/credo.vim
+++ b/ale_linters/elixir/credo.vim
@@ -7,13 +7,7 @@ function! ale_linters#elixir#credo#Handle(buffer, lines) abort
let l:pattern = '\v:(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = l:match[3]
let l:text = l:match[4]
diff --git a/ale_linters/elixir/dogma.vim b/ale_linters/elixir/dogma.vim
index 0e4c684d..e3b24711 100644
--- a/ale_linters/elixir/dogma.vim
+++ b/ale_linters/elixir/dogma.vim
@@ -7,13 +7,7 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort
let l:pattern = '\v:(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = l:match[3]
let l:text = l:match[4]
diff --git a/ale_linters/haml/hamllint.vim b/ale_linters/haml/hamllint.vim
index fead7472..b1a6aa57 100644
--- a/ale_linters/haml/hamllint.vim
+++ b/ale_linters/haml/hamllint.vim
@@ -7,15 +7,8 @@ function! ale_linters#haml#hamllint#Handle(buffer, lines) abort
let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2],
\ 'text': l:match[3]
diff --git a/ale_linters/html/tidy.vim b/ale_linters/html/tidy.vim
index 764bea82..c9fdbc7c 100644
--- a/ale_linters/html/tidy.vim
+++ b/ale_linters/html/tidy.vim
@@ -43,20 +43,13 @@ function! ale_linters#html#tidy#Handle(buffer, lines) abort
let l:pattern = '^line \(\d\+\) column \(\d\+\) - \(Warning\|Error\): \(.\+\)$'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:col = l:match[2] + 0
let l:type = l:match[3] ==# 'Error' ? 'E' : 'W'
let l:text = l:match[4]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'col': l:col,
\ 'text': l:text,
diff --git a/ale_linters/java/javac.vim b/ale_linters/java/javac.vim
index 9c9962a9..186d3834 100644
--- a/ale_linters/java/javac.vim
+++ b/ale_linters/java/javac.vim
@@ -28,15 +28,8 @@ function! ale_linters#java#javac#Handle(buffer, lines) abort
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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'text': l:match[2] . ':' . l:match[3],
\ 'type': l:match[2] ==# 'error' ? 'E' : 'W',
diff --git a/ale_linters/javascript/eslint.vim b/ale_linters/javascript/eslint.vim
index 459e4e5d..1a59ff12 100644
--- a/ale_linters/javascript/eslint.vim
+++ b/ale_linters/javascript/eslint.vim
@@ -66,18 +66,7 @@ function! ale_linters#javascript#eslint#Handle(buffer, lines) abort
let l:parsing_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
- " Try the parsing pattern for parsing errors.
- let l:match = matchlist(l:line, l:parsing_pattern)
- endif
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, [l:pattern, l:parsing_pattern])
let l:type = 'Error'
let l:text = l:match[3]
diff --git a/ale_linters/javascript/standard.vim b/ale_linters/javascript/standard.vim
index 8809b07e..895d9951 100644
--- a/ale_linters/javascript/standard.vim
+++ b/ale_linters/javascript/standard.vim
@@ -37,13 +37,7 @@ function! ale_linters#javascript#standard#Handle(buffer, lines) abort
let l: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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:type = 'Error'
let l:text = l:match[3]
diff --git a/ale_linters/json/jsonlint.vim b/ale_linters/json/jsonlint.vim
index 83e74c71..75f47088 100644
--- a/ale_linters/json/jsonlint.vim
+++ b/ale_linters/json/jsonlint.vim
@@ -7,19 +7,11 @@ function! ale_linters#json#jsonlint#Handle(buffer, lines) abort
let l:pattern = '^line \(\d\+\), col \(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[3],
- \ 'type': 'E',
\})
endfor
diff --git a/ale_linters/lua/luacheck.vim b/ale_linters/lua/luacheck.vim
index c73c775e..d4c1b242 100644
--- a/ale_linters/lua/luacheck.vim
+++ b/ale_linters/lua/luacheck.vim
@@ -21,15 +21,8 @@ function! ale_linters#lua#luacheck#Handle(buffer, lines) abort
let l:pattern = '^.*:\(\d\+\):\(\d\+\): (\([WE]\)\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
diff --git a/ale_linters/markdown/mdl.vim b/ale_linters/markdown/mdl.vim
index 7e64304c..f2390250 100644
--- a/ale_linters/markdown/mdl.vim
+++ b/ale_linters/markdown/mdl.vim
@@ -6,17 +6,9 @@ function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
- \ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\})
diff --git a/ale_linters/matlab/mlint.vim b/ale_linters/matlab/mlint.vim
index 68f9cf81..851e398a 100644
--- a/ale_linters/matlab/mlint.vim
+++ b/ale_linters/matlab/mlint.vim
@@ -22,13 +22,7 @@ function! ale_linters#matlab#mlint#Handle(buffer, lines) abort
let l:pattern = '^L \(\d\+\) (C \([0-9-]\+\)): \([A-Z]\+\): \(.\+\)$'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:lnum = l:match[1] + 0
let l:col = l:match[2] + 0
let l:code = l:match[3]
diff --git a/ale_linters/nim/nimcheck.vim b/ale_linters/nim/nimcheck.vim
index 92120970..61af070c 100644
--- a/ale_linters/nim/nimcheck.vim
+++ b/ale_linters/nim/nimcheck.vim
@@ -6,13 +6,7 @@ function! ale_linters#nim#nimcheck#Handle(buffer, lines) abort
let l:pattern = '^\(.\+\.nim\)(\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
" Only show errors of the current buffer
" NOTE: Checking filename only is OK because nim enforces unique
" module names.
diff --git a/ale_linters/nix/nix.vim b/ale_linters/nix/nix.vim
index 96baa3b8..0a0c5c3e 100644
--- a/ale_linters/nix/nix.vim
+++ b/ale_linters/nix/nix.vim
@@ -5,15 +5,8 @@ function! ale_linters#nix#nix#Handle(buffer, lines) abort
let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[3] + 0,
\ 'col': l:match[4] + 0,
\ 'text': l:match[1] . ': ' . l:match[2],
diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim
index 7e48efc3..8720213b 100644
--- a/ale_linters/perl/perl.vim
+++ b/ale_linters/perl/perl.vim
@@ -21,19 +21,12 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
let l:pattern = '\(.\+\) at \(.\+\) line \(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[3]
let l:text = l:match[1]
let l:type = 'E'
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'text': l:text,
\ 'type': l:type,
diff --git a/ale_linters/perl/perlcritic.vim b/ale_linters/perl/perlcritic.vim
index 8f31e513..f0e85030 100644
--- a/ale_linters/perl/perlcritic.vim
+++ b/ale_linters/perl/perlcritic.vim
@@ -5,22 +5,10 @@ function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort
let l:pattern = '\(.\+\) at \(.\+\) line \(\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
-
- let l:line = l:match[3]
- let l:text = l:match[1]
- let l:type = 'E'
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
- \ 'lnum': l:line,
- \ 'text': l:text,
- \ 'type': l:type,
+ \ 'text': l:match[1],
+ \ 'lnum': l:match[3],
\})
endfor
diff --git a/ale_linters/php/hack.vim b/ale_linters/php/hack.vim
index 762486b4..77d3a588 100644
--- a/ale_linters/php/hack.vim
+++ b/ale_linters/php/hack.vim
@@ -5,23 +5,15 @@ function! ale_linters#php#hack#Handle(buffer, lines) abort
let l:pattern = '^\(.*\):\(\d\+\):\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
if a:buffer != bufnr(l:match[1])
- continue
+ continue
endif
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[5],
- \ 'type': 'E',
\})
endfor
diff --git a/ale_linters/php/php.vim b/ale_linters/php/php.vim
index 3f354de5..6d151686 100644
--- a/ale_linters/php/php.vim
+++ b/ale_linters/php/php.vim
@@ -9,19 +9,11 @@ function! ale_linters#php#php#Handle(buffer, lines) abort
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[3] + 0,
\ 'col': empty(l:match[2]) ? 0 : stridx(getline(l:match[3]), l:match[2]) + 1,
\ 'text': l:match[1],
- \ 'type': 'E',
\})
endfor
diff --git a/ale_linters/php/phpcs.vim b/ale_linters/php/phpcs.vim
index 15e1457a..94c887c4 100644
--- a/ale_linters/php/phpcs.vim
+++ b/ale_linters/php/phpcs.vim
@@ -19,18 +19,11 @@ function! ale_linters#php#phpcs#Handle(buffer, lines) abort
let l: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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:text = l:match[4]
let l:type = l:match[3]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
diff --git a/ale_linters/php/phpmd.vim b/ale_linters/php/phpmd.vim
index 02b98306..29d8103a 100644
--- a/ale_linters/php/phpmd.vim
+++ b/ale_linters/php/phpmd.vim
@@ -17,17 +17,9 @@ function! ale_linters#php#phpmd#Handle(buffer, lines) abort
let l:pattern = '^.*:\(\d\+\)\t\(.\+\)$'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
- \ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\})
diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim
index 12bc980e..47e89d34 100644
--- a/ale_linters/puppet/puppet.vim
+++ b/ale_linters/puppet/puppet.vim
@@ -7,19 +7,11 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort
let l:pattern = '^Error: .*: \(.\+\) at .\+:\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[2] + 0,
\ 'col': l:match[3] + 0,
\ 'text': l:match[1],
- \ 'type': 'E',
\})
endfor
diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim
index 257a1d39..8c432f86 100644
--- a/ale_linters/python/mypy.vim
+++ b/ale_linters/python/mypy.vim
@@ -28,13 +28,7 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
if l:match[4] =~# 'Stub files are from'
" The lines telling us where to get stub files from make it so
" we can't read the actual errors, so exclude them.
@@ -42,7 +36,6 @@ function! ale_linters#python#mypy#Handle(buffer, lines) abort
endif
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
diff --git a/ale_linters/ruby/rubocop.vim b/ale_linters/ruby/rubocop.vim
index fe5d3443..95cb5516 100644
--- a/ale_linters/ruby/rubocop.vim
+++ b/ale_linters/ruby/rubocop.vim
@@ -9,18 +9,11 @@ function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
let l:pattern = '\v:(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:text = l:match[4]
let l:type = l:match[3]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:text,
diff --git a/ale_linters/ruby/ruby.vim b/ale_linters/ruby/ruby.vim
index 7cffcf3a..1ed9d429 100644
--- a/ale_linters/ruby/ruby.vim
+++ b/ale_linters/ruby/ruby.vim
@@ -19,7 +19,6 @@ function! ale_linters#ruby#ruby#Handle(buffer, lines) abort
endif
else
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': 0,
\ 'text': l:match[2] . l:match[3],
diff --git a/ale_linters/scala/scalac.vim b/ale_linters/scala/scalac.vim
index c6ab9c6d..4bc0cb8d 100644
--- a/ale_linters/scala/scalac.vim
+++ b/ale_linters/scala/scalac.vim
@@ -26,7 +26,6 @@ function! ale_linters#scala#scalac#Handle(buffer, lines) abort
endif
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:col + 1,
\ 'text': l:text,
diff --git a/ale_linters/scss/scsslint.vim b/ale_linters/scss/scsslint.vim
index 34db37ea..d75743a3 100644
--- a/ale_linters/scss/scsslint.vim
+++ b/ale_linters/scss/scsslint.vim
@@ -8,20 +8,13 @@ function! ale_linters#scss#scsslint#Handle(buffer, lines) abort
let l: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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
if g:ale_warn_about_trailing_whitespace && l:match[4] =~# '^TrailingWhitespace'
" Skip trailing whitespace warnings if that option is on.
continue
endif
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4],
diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim
index 372c1729..cd363091 100644
--- a/ale_linters/sh/shell.vim
+++ b/ale_linters/sh/shell.vim
@@ -41,22 +41,10 @@ function! ale_linters#sh#shell#Handle(buffer, lines) abort
let l:pattern = '\v(line |: ?)(\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
-
- let l:line = l:match[2] + 0
- let l:text = l:match[3]
- let l:type = 'E'
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
- \ 'lnum': l:line,
- \ 'text': l:text,
- \ 'type': l:type,
+ \ 'lnum': str2nr(l:match[2]),
+ \ 'text': l:match[3],
\})
endfor
diff --git a/ale_linters/slim/slimlint.vim b/ale_linters/slim/slimlint.vim
index 8613951b..74796b2b 100644
--- a/ale_linters/slim/slimlint.vim
+++ b/ale_linters/slim/slimlint.vim
@@ -7,15 +7,8 @@ function! ale_linters#slim#slimlint#Handle(buffer, lines) abort
let l:pattern = '\v^.*:(\d+) \[([EW])\] (.+)$'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'type': l:match[2],
\ 'text': l:match[3]
diff --git a/ale_linters/sql/sqlint.vim b/ale_linters/sql/sqlint.vim
index d8bf9dce..ca893724 100644
--- a/ale_linters/sql/sqlint.vim
+++ b/ale_linters/sql/sqlint.vim
@@ -8,13 +8,7 @@ function! ale_linters#sql#sqlint#Handle(buffer, lines) abort
let l:pattern = '\v^[^:]+:(\d+):(\d+):(\u+) (.*)'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if empty(l:match)
- continue
- endif
-
+ 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,
diff --git a/ale_linters/tex/chktex.vim b/ale_linters/tex/chktex.vim
index 8ecb3773..c65deede 100644
--- a/ale_linters/tex/chktex.vim
+++ b/ale_linters/tex/chktex.vim
@@ -34,15 +34,8 @@ function! ale_linters#tex#chktex#Handle(buffer, lines) abort
let l:pattern = '^stdin:\(\d\+\):\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'col': l:match[2] + 0,
\ 'text': l:match[4] . ' (' . (l:match[3]+0) . ')',
diff --git a/ale_linters/tex/lacheck.vim b/ale_linters/tex/lacheck.vim
index de8e76ab..e5a9632b 100644
--- a/ale_linters/tex/lacheck.vim
+++ b/ale_linters/tex/lacheck.vim
@@ -21,13 +21,7 @@ function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
let l:pattern = '^".\+", line \(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
" lacheck follows `\input{}` commands. If the cwd is not the same as the
" file in the buffer then it will fail to find the inputed items. We do not
" want warnings from those items anyway
@@ -36,9 +30,7 @@ function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
endif
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
- \ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\})
diff --git a/ale_linters/typescript/tslint.vim b/ale_linters/typescript/tslint.vim
index 081ad42b..247aeb43 100644
--- a/ale_linters/typescript/tslint.vim
+++ b/ale_linters/typescript/tslint.vim
@@ -25,24 +25,15 @@ function! ale_linters#typescript#tslint#Handle(buffer, lines) abort
let l:pattern = '.\+' . l:ext . '\[\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:column = l:match[2] + 0
- let l:type = 'E'
let l:text = l:match[3]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'col': l:column,
\ 'text': l:text,
- \ 'type': l:type,
\})
endfor
diff --git a/ale_linters/typescript/typecheck.vim b/ale_linters/typescript/typecheck.vim
index 2362b3c9..2f18691b 100644
--- a/ale_linters/typescript/typecheck.vim
+++ b/ale_linters/typescript/typecheck.vim
@@ -10,24 +10,15 @@ function! ale_linters#typescript#typecheck#Handle(buffer, lines) abort
let l:pattern = '.\+\.ts\[\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:column = l:match[2] + 0
- let l:type = 'E'
let l:text = l:match[3]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'col': l:column,
\ 'text': l:text,
- \ 'type': l:type,
\})
endfor
diff --git a/ale_linters/verilog/iverilog.vim b/ale_linters/verilog/iverilog.vim
index a061e473..0f4cd7b3 100644
--- a/ale_linters/verilog/iverilog.vim
+++ b/ale_linters/verilog/iverilog.vim
@@ -11,19 +11,12 @@ function! ale_linters#verilog#iverilog#Handle(buffer, lines) abort
let l:pattern = '^[^:]\+:\(\d\+\): \(warning\|error\|syntax error\)\(: \(.\+\)\)\?'
let l:output = []
- for l:line in a:lines
- let l:match = matchlist(l:line, l:pattern)
-
- if len(l:match) == 0
- continue
- endif
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:type = l:match[2] =~# 'error' ? 'E' : 'W'
let l:text = l:match[2] ==# 'syntax error' ? 'syntax error' : l:match[4]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'text': l:text,
\ 'type': l:type,
diff --git a/ale_linters/verilog/verilator.vim b/ale_linters/verilog/verilator.vim
index fbff2b2e..e2dbafac 100644
--- a/ale_linters/verilog/verilator.vim
+++ b/ale_linters/verilog/verilator.vim
@@ -23,13 +23,7 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[3] + 0
let l:type = l:match[1] ==# 'Error' ? 'E' : 'W'
let l:text = l:match[4]
@@ -37,7 +31,6 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
if l:file =~# '_verilator_linted.v'
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'text': l:text,
\ 'type': l:type,
diff --git a/ale_linters/yaml/yamllint.vim b/ale_linters/yaml/yamllint.vim
index d8671cbd..a0eb2a0a 100644
--- a/ale_linters/yaml/yamllint.vim
+++ b/ale_linters/yaml/yamllint.vim
@@ -23,20 +23,13 @@ function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort
let l:pattern = '^.*:\(\d\+\):\(\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
-
+ for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[1] + 0
let l:col = l:match[2] + 0
let l:type = l:match[3]
let l:text = l:match[4]
call add(l:output, {
- \ 'bufnr': a:buffer,
\ 'lnum': l:line,
\ 'col': l:col,
\ 'text': l:text,
diff --git a/autoload/ale/util.vim b/autoload/ale/util.vim
index 37085432..b796d638 100644
--- a/autoload/ale/util.vim
+++ b/autoload/ale/util.vim
@@ -101,3 +101,27 @@ endfunction
function! ale#util#ClockMilliseconds() abort
return float2nr(reltimefloat(reltime()) * 1000)
endfunction
+
+" Given a single line, or a List of lines, and a single pattern, or a List
+" of patterns, return all of the matches for the lines(s) from the given
+" patterns, using matchlist().
+"
+" Only the first pattern which matches a line will be returned.
+function! ale#util#GetMatches(lines, patterns) abort
+ let l:matches = []
+ let l:lines = type(a:lines) == type([]) ? a:lines : [a:lines]
+ let l:patterns = type(a:patterns) == type([]) ? a:patterns : [a:patterns]
+
+ for l:line in l:lines
+ for l:pattern in l:patterns
+ let l:match = matchlist(l:line, l:pattern)
+
+ if !empty(l:match)
+ call add(l:matches, l:match)
+ break
+ endif
+ endfor
+ endfor
+
+ return l:matches
+endfunction
diff --git a/test/handler/test_asm_handler.vader b/test/handler/test_asm_handler.vader
index 7cee7783..2868628f 100644
--- a/test/handler/test_asm_handler.vader
+++ b/test/handler/test_asm_handler.vader
@@ -4,22 +4,14 @@ Execute(The asm GCC handler should parse lines from GCC 6.3.1 correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 357,
\ 'lnum': 38,
- \ 'vcol': 0,
- \ 'col': 0,
\ 'text': "too many memory references for `mov'",
\ 'type': 'E',
- \ 'nr': -1,
\ },
\ {
- \ 'bufnr': 357,
\ 'lnum': 42,
- \ 'vcol': 0,
- \ 'col': 0,
\ 'text': "incorrect register `%ax' used with `l' suffix",
\ 'type': 'E',
- \ 'nr': -1,
\ },
\ ],
\ ale_linters#asm#gcc#Handle(357, [
diff --git a/test/handler/test_coffeelint_handler.vader b/test/handler/test_coffeelint_handler.vader
index 10370221..4426e44e 100644
--- a/test/handler/test_coffeelint_handler.vader
+++ b/test/handler/test_coffeelint_handler.vader
@@ -4,7 +4,6 @@ Execute(The coffeelint handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 125,
\ 'text': "Line exceeds maximum allowed length Length is 122, max is 120.",
\ 'type': 'E',
diff --git a/test/handler/test_mypy_handler.vader b/test/handler/test_mypy_handler.vader
index e161f8ae..77e678e4 100644
--- a/test/handler/test_mypy_handler.vader
+++ b/test/handler/test_mypy_handler.vader
@@ -4,14 +4,12 @@ Execute(The mypy handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 4,
\ 'col': 0,
\ 'text': "No library stub file for module 'django.db'",
\ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 40,
\ 'col': 5,
\ 'text': "Some other problem",
diff --git a/test/handler/test_nix_handler.vader b/test/handler/test_nix_handler.vader
index a58c93de..1555e59d 100644
--- a/test/handler/test_nix_handler.vader
+++ b/test/handler/test_nix_handler.vader
@@ -4,14 +4,12 @@ Execute(The nix handler should parse nix-instantiate error messages correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 47,
\ 'lnum': 23,
\ 'col': 14,
\ 'text': 'error: syntax error, unexpected IN',
\ 'type': 'E',
\ },
\ {
- \ 'bufnr': 47,
\ 'lnum': 3,
\ 'col': 12,
\ 'text': 'error: syntax error, unexpected ''='', expecting '';''',
diff --git a/test/handler/test_php_handler.vader b/test/handler/test_php_handler.vader
index e7c5dc29..086a4f6a 100644
--- a/test/handler/test_php_handler.vader
+++ b/test/handler/test_php_handler.vader
@@ -11,53 +11,39 @@ Execute(The php handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 1,
\ 'col': 5,
\ 'text': "syntax error, unexpected ';', expecting ']'",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 2,
\ 'col': 13,
\ 'text': "syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST)",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 3,
\ 'col': 5,
\ 'text': "syntax error, unexpected ')'",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 4,
\ 'col': 8,
\ 'text': "syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 5,
\ 'col': 0,
\ 'text': "Cannot redeclare count()",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 21,
\ 'col': 0,
\ 'text': "syntax error, unexpected end of file",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 47,
\ 'col': 0,
\ 'text': "Invalid numeric literal",
- \ 'type': 'E',
\ },
\ ],
\ ale_linters#php#php#Handle(347, [
diff --git a/test/handler/test_rubocop_handler.vader b/test/handler/test_rubocop_handler.vader
index d77aa83c..8fa8374a 100644
--- a/test/handler/test_rubocop_handler.vader
+++ b/test/handler/test_rubocop_handler.vader
@@ -4,28 +4,24 @@ Execute(The rubocop handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 83,
\ 'col': 29,
\ 'text': 'Prefer single-quoted strings...',
\ 'type': 'W',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 12,
\ 'col': 2,
\ 'text': 'Some error',
\ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 10,
\ 'col': 5,
\ 'text': 'Regular warning',
\ 'type': 'W',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 11,
\ 'col': 1,
\ 'text': 'Another error',
diff --git a/test/handler/test_ruby_handler.vader b/test/handler/test_ruby_handler.vader
index 573711f7..ed8b06e2 100644
--- a/test/handler/test_ruby_handler.vader
+++ b/test/handler/test_ruby_handler.vader
@@ -7,21 +7,18 @@ Execute(The ruby handler should parse lines correctly and add the column if it c
\ [
\ {
\ 'lnum': 6,
- \ 'bufnr': 255,
\ 'col': 13,
\ 'type': 'E',
\ 'text': 'syntax error, unexpected '';'''
\ },
\ {
\ 'lnum': 9,
- \ 'bufnr': 255,
\ 'col': 0,
\ 'type': 'W',
\ 'text': 'warning: statement not reached'
\ },
\ {
\ 'lnum': 12,
- \ 'bufnr': 255,
\ 'col': 0,
\ 'type': 'E',
\ 'text': 'syntax error, unexpected end-of-input, expecting keyword_end'
diff --git a/test/handler/test_shell_handler.vader b/test/handler/test_shell_handler.vader
index 12506821..ecfbf02b 100644
--- a/test/handler/test_shell_handler.vader
+++ b/test/handler/test_shell_handler.vader
@@ -7,40 +7,28 @@ Execute(The shell handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 13,
\ 'text': 'syntax error near unexpected token d',
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 7,
\ 'text': 'line 42: line 36:',
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 11,
\ 'text': 'Syntax error: "(" unexpected',
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 95,
\ 'text': 'parse error near `out=$(( $1 / 1024. )...',
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 22,
\ 'text': ':11: :33: :44:',
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 9,
\ 'text': '`done'' unexpected',
- \ 'type': 'E',
\ },
\ ],
\ ale_linters#sh#shell#Handle(347, [
diff --git a/test/handler/test_slim_handler.vader b/test/handler/test_slim_handler.vader
index 12bd8183..21c1ec90 100644
--- a/test/handler/test_slim_handler.vader
+++ b/test/handler/test_slim_handler.vader
@@ -6,19 +6,16 @@ Execute(The slim handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 1,
\ 'text': 'RedundantDiv: `div` is redundant when class attribute shortcut is present',
\ 'type': 'W',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 2,
\ 'text': 'LineLength: Line is too long. [136/80]',
\ 'type': 'W',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 3,
\ 'text': 'Invalid syntax',
\ 'type': 'E',
diff --git a/test/handler/test_typecheck_handler.vader b/test/handler/test_typecheck_handler.vader
index e42bcaf3..cf93798e 100644
--- a/test/handler/test_typecheck_handler.vader
+++ b/test/handler/test_typecheck_handler.vader
@@ -4,18 +4,14 @@ Execute(The typecheck handler should parse lines correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 347,
\ 'lnum': 16,
\ 'col': 7,
\ 'text': "Type 'A' is not assignable to type 'B'",
- \ 'type': 'E',
\ },
\ {
- \ 'bufnr': 347,
\ 'lnum': 7,
\ 'col': 41,
\ 'text': "Property 'a' does not exist on type 'A'",
- \ 'type': 'E',
\ },
\ ],
\ ale_linters#typescript#typecheck#Handle(347, [
diff --git a/test/test_getmatches.vader b/test/test_getmatches.vader
new file mode 100644
index 00000000..e728b571
--- /dev/null
+++ b/test/test_getmatches.vader
@@ -0,0 +1,148 @@
+Execute (ale#util#GetMatches should return matches for many lines):
+ AssertEqual
+ \ [
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '47',
+ \ '14',
+ \ 'Missing trailing comma.',
+ \ 'Warning/comma-dangle',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ [
+ \ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
+ \ '56',
+ \ '41',
+ \ 'Missing semicolon.',
+ \ 'Error/semi',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ ],
+ \ ale#util#GetMatches(
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
+ \ ],
+ \ [
+ \ '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$',
+ \ ]
+ \ )
+
+Execute (ale#util#GetMatches should accept a string for a single pattern):
+ AssertEqual
+ \ [
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '47',
+ \ '14',
+ \ 'Missing trailing comma.',
+ \ 'Warning/comma-dangle',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ [
+ \ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
+ \ '56',
+ \ '41',
+ \ 'Missing semicolon.',
+ \ 'Error/semi',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ ],
+ \ ale#util#GetMatches(
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
+ \ ],
+ \ '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$'
+ \ )
+
+Execute (ale#util#GetMatches should accept a single line as a string):
+ AssertEqual
+ \ [
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '47',
+ \ '14',
+ \ 'Missing trailing comma.',
+ \ 'Warning/comma-dangle',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ ],
+ \ ale#util#GetMatches(
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ [
+ \ '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$',
+ \ ]
+ \ )
+
+Execute (ale#util#GetMatches should match multiple patterns correctly):
+ AssertEqual
+ \ [
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '47',
+ \ '14',
+ \ 'Missing trailing comma.',
+ \ 'Warning/comma-dangle',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ [
+ \ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
+ \ '56',
+ \ '41',
+ \ 'Missing semicolon.',
+ \ 'Error/semi',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ [
+ \ '/path/to/some-filename.js:13:3: Parsing error: Unexpected token',
+ \ '13',
+ \ '3',
+ \ 'Parsing error: Unexpected token',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ '',
+ \ ],
+ \ ],
+ \ ale#util#GetMatches(
+ \ [
+ \ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
+ \ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
+ \ '/path/to/some-filename.js:13:3: Parsing error: Unexpected token',
+ \ ],
+ \ [
+ \ '^.*:\(\d\+\):\(\d\+\): \(.\+\) \[\(.\+\)\]$',
+ \ '^.*:\(\d\+\):\(\d\+\): \(.\+\)$',
+ \ ]
+ \ )