From 38d25fc7c04c19724f6be53b4c2de530dd55d671 Mon Sep 17 00:00:00 2001 From: Mark Grimes Date: Fri, 14 Dec 2018 16:14:54 -0500 Subject: [PATCH 1/3] Update the perl-linter's l:pattern to catch missing errors In some situations, errors reported by `perl -c` can have multiple listings of "at line ". If the l:pattern is changed to use non-greedy matching it will also match these. For example: ``` use strict; use DateTime; $asdf=1; ``` Results in: ``` Global symbol "$asdf" requires explicit package name (did you forget to declare "my $asdf"?) at /Users/mgrimes/t.pl line 3, line 1. /Users/mgrimes/t.pl had compilation errors. ``` I am not 100% sure why `perl -c` generates errors with the extra "file line ". It only happens in some versions of perl when certain modules are used. --- ale_linters/perl/perl.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index 1cb20fa7..131e7152 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -18,7 +18,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort return [] endif - let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\)' + let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\),' let l:output = [] let l:basename = expand('#' . a:buffer . ':t') From ebab81b22032d4287d452ea5b87c000c186e0e00 Mon Sep 17 00:00:00 2001 From: Mark Grimes Date: Sun, 16 Dec 2018 17:01:24 -0500 Subject: [PATCH 2/3] Use non-greedy matching instead of looking for the comma --- ale_linters/perl/perl.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim index 131e7152..4b954f0d 100644 --- a/ale_linters/perl/perl.vim +++ b/ale_linters/perl/perl.vim @@ -18,7 +18,7 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort return [] endif - let l:pattern = '\(.\+\) at \(.\+\) line \(\d\+\),' + let l:pattern = '\(..\{-}\) at \(..\{-}\) line \(\d\+\)' let l:output = [] let l:basename = expand('#' . a:buffer . ':t') From c19f2aa3027b86b02eebefbdd962b48754a111c5 Mon Sep 17 00:00:00 2001 From: Mark Grimes Date: Wed, 19 Dec 2018 08:30:23 -0500 Subject: [PATCH 3/3] Adds tests for perl-linter where a second file/line is included in error --- test/handler/test_perl_handler.vader | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/handler/test_perl_handler.vader b/test/handler/test_perl_handler.vader index e769550c..060b1ffe 100644 --- a/test/handler/test_perl_handler.vader +++ b/test/handler/test_perl_handler.vader @@ -91,3 +91,19 @@ Execute(The Perl linter reports errors even when mixed with warnings): \ 'syntax error at - line 8, at EOF', \ 'Execution of t.pl aborted due to compilation errors.', \ ]) + +Execute(The Perl linter reports errors even when an additional file location is included): + AssertEqual + \ [ + \ {'lnum': '5', 'type': 'E', 'text': '"my" variable $foo masks earlier declaration in same scope'}, + \ {'lnum': '6', 'type': 'E', 'text': '"my" variable $foo masks earlier declaration in same scope'}, + \ {'lnum': '11', 'type': 'E', 'text': 'Global symbol "$asdf" requires explicit package name (did you forget to declare "my $asdf"?)'}, + \ {'lnum': '12', 'type': 'E', 'text': 'Global symbol "$asdf" requires explicit package name (did you forget to declare "my $asdf"?)'}, + \ ], + \ ale_linters#perl#perl#Handle(bufnr(''), [ + \ '"my" variable $foo masks earlier declaration in same scope at - line 5.', + \ '"my" variable $foo masks earlier declaration in same scope at - line 6, at line 1.', + \ 'Global symbol "$asdf" requires explicit package name (did you forget to declare "my $asdf"?) at - line 11.', + \ 'Global symbol "$asdf" requires explicit package name (did you forget to declare "my $asdf"?) at - line 12, line 1.', + \ 'Execution of t.pl aborted due to compilation errors.', + \ ])