summaryrefslogtreecommitdiff
path: root/ale_linters/perl/perl.vim
diff options
context:
space:
mode:
authorOlaf Alders <olaf@wundersolutions.com>2018-03-02 16:04:52 -0500
committerw0rp <w0rp@users.noreply.github.com>2018-03-02 21:04:52 +0000
commit8a772905539ccfe306219addae5a506def88fe44 (patch)
tree173d357160287312a1ab55580ddfed99ce1b9009 /ale_linters/perl/perl.vim
parentb6bf6ecdbc692f05f0f89eee31018c2d659b35aa (diff)
downloadale-8a772905539ccfe306219addae5a506def88fe44.zip
[WIP] Begin to distinguish between Perl warnings and errors (#933)
* If a Perl script compiles, there are only warnings and no errors * Let the first Perl error or warning win. Take the following example: *** sub foo { my $thing; *** This might have the following messages when we compile it: Missing right curly or square bracket at warning.pl line 7, at end of line syntax error at warning.pl line 7, at EOF warning.pl had compilation errors. With the current behaviour, we just get a "syntax error" message, which isn't all that helpful. With this patch we get "Missing right curly or square bracket". * Fix variable scope and pattern matching syntax * Use named variable to enhance clarity when matching Perl output * Add more tests for Perl linter * Remove unnecessary parens * Simplify check for pattern match
Diffstat (limited to 'ale_linters/perl/perl.vim')
-rw-r--r--ale_linters/perl/perl.vim14
1 files changed, 12 insertions, 2 deletions
diff --git a/ale_linters/perl/perl.vim b/ale_linters/perl/perl.vim
index fcc88f35..1b9aa95e 100644
--- a/ale_linters/perl/perl.vim
+++ b/ale_linters/perl/perl.vim
@@ -27,12 +27,20 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
let l:output = []
let l:basename = expand('#' . a:buffer . ':t')
+ let l:type = 'E'
+ if a:lines[-1] =~# 'syntax OK'
+ let l:type = 'W'
+ endif
+
+ let l:seen = {}
+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let l:line = l:match[3]
+ let l:file = l:match[2]
let l:text = l:match[1]
- let l:type = 'E'
- if ale#path#IsBufferPath(a:buffer, l:match[2])
+ if ale#path#IsBufferPath(a:buffer, l:file)
+ \ && !has_key(l:seen,l:line)
\ && (
\ l:text isnot# 'BEGIN failed--compilation aborted'
\ || empty(l:output)
@@ -43,6 +51,8 @@ function! ale_linters#perl#perl#Handle(buffer, lines) abort
\ 'text': l:text,
\ 'type': l:type,
\})
+
+ let l:seen[l:line] = 1
endif
endfor