diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index f4b35ab..087d03e 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -17,6 +17,11 @@ function! ale_linters#perl#perl#GetCommand(buffer) abort \ . ' %t' endfunction +let s:begin_failed_skip_pattern = '\v' . join([ +\ '^Compilation failed in require', +\ '^Can''t locate', +\], '|') + function! ale_linters#perl#perl#Handle(buffer, lines) abort let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' let l:output = [] @@ -28,7 +33,11 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort let l:type = 'E' if ale#path#IsBufferPath(a:buffer, l:match[2]) - \&& l:text !=# 'BEGIN failed--compilation aborted' + \ && ( + \ l:text !=# 'BEGIN failed--compilation aborted' + \ || empty(l:output) + \ || match(l:output[-1].text, s:begin_failed_skip_pattern) < 0 + \ ) call add(l:output, { \ 'lnum': l:line, \ 'text': l:text, diff --git a/test/handler/test_perl_handler.vader b/test/handler/test_perl_handler.vader index 1effd68..3ada9aa 100644 --- a/test/handler/test_perl_handler.vader +++ b/test/handler/test_perl_handler.vader @@ -36,3 +36,17 @@ Execute(The Perl linter should complain about failing to locate modules): \ 'Can''t locate JustOneDb.pm in @INC (you may need to install the JustOneDb module) (@INC contains: /home/local/sean/work/PostgreSQL/6616/../../../../lib /home/local/sean/work/PostgreSQL/6616/lib lib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at - line 23.', \ 'BEGIN failed--compilation aborted at - line 23.', \ ]) + + +Execute(The Perl linter should complain about failing to locate modules): + AssertEqual + \ [ + \ {'lnum': '8', 'type': 'E', 'text': 'BEGIN failed--compilation aborted'}, + \ {'lnum': '10', 'type': 'E', 'text': 'BEGIN failed--compilation aborted'} + \ ], + \ ale_linters#perl#perl#Handle(bufnr(''), [ + \ 'Unable to build `ro` accessor for slot `path` in `App::CPANFileUpdate` because the slot cannot be found. at /extlib/Method/Traits.pm line 189.', + \ 'BEGIN failed--compilation aborted at - line 8.', + \ 'Unable to build `ro` accessor for slot `path` in `App::CPANFileUpdate` because the slot cannot be found. at /extlib/Method/Traits.pm line 189.', + \ 'BEGIN failed--compilation aborted at - line 10.', + \ ])