All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Vincent Lequertier <https://github.com/SkySymbol>, Chris Weyl <cweyl@alumni.drew.edu>
2 " Description: This file adds support for checking perl with perl critic
4 call ale#Set('perl_perlcritic_executable', 'perlcritic')
5 call ale#Set('perl_perlcritic_profile', '.perlcriticrc')
6 call ale#Set('perl_perlcritic_options', '')
7 call ale#Set('perl_perlcritic_showrules', 0)
9 function! ale_linters#perl#perlcritic#GetProfile(buffer) abort
10 " first see if we've been overridden
11 let l:profile = ale#Var(a:buffer, 'perl_perlcritic_profile')
17 " otherwise, iterate upwards to find it
18 return ale#path#FindNearestFile(a:buffer, l:profile)
21 function! ale_linters#perl#perlcritic#GetCommand(buffer) abort
22 let l:critic_verbosity = '%l:%c %m\n'
24 if ale#Var(a:buffer, 'perl_perlcritic_showrules')
25 let l:critic_verbosity = '%l:%c %m [%p]\n'
28 let l:profile = ale_linters#perl#perlcritic#GetProfile(a:buffer)
29 let l:options = ale#Var(a:buffer, 'perl_perlcritic_options')
32 \ . ' --verbose ' . ale#Escape(l:critic_verbosity)
34 \ . (!empty(l:profile) ? ' --profile ' . ale#Escape(l:profile) : '')
35 \ . ale#Pad(l:options)
39 function! ale_linters#perl#perlcritic#Handle(buffer, lines) abort
40 let l:pattern = '\(\d\+\):\(\d\+\) \(.\+\)'
43 for l:match in ale#util#GetMatches(a:lines, l:pattern)
55 call ale#linter#Define('perl', {
56 \ 'name': 'perlcritic',
57 \ 'output_stream': 'stdout',
58 \ 'executable': {b -> ale#Var(b, 'perl_perlcritic_executable')},
59 \ 'command': function('ale_linters#perl#perlcritic#GetCommand'),
60 \ 'callback': 'ale_linters#perl#perlcritic#Handle',