Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing Ale to display Perl::Critic violations as warnings rather than errors

I'm using vim with the Ale plugin. By default, perlcritic violations show up as errors. I'd like to see them displayed as warnings. According to :help g:ale_type_map I should be able to do this, but it isn't clear to me exactly how.

let g:ale_type_map = {'perl': {'E': 'W'}} will change perl errors into warnings.

let g:ale_type_map = {'perl': {'ES': 'WS'}} does not appear to have any effect on the critic violations. Neither do either of these:

let g:ale_type_map = {'perlcritic': {'ES': 'WS', 'E': 'W'}}
let g:ale_type_map = {'perl_perlcritic': {'ES': 'WS', 'E': 'W'}}

The docs on this are pretty sparse, so I'm unclear on whether it's an issue with syntax, linter name or something else entirely.

like image 984
oalders Avatar asked Nov 07 '22 17:11

oalders


1 Answers

After hearing from the author, this is the correct syntax, which allows you to set options for both perltidy and Perl::Critic:

let g:ale_type_map = {
\    'perl': {'ES': 'WS'}, 
\    'perlcritic': {'ES': 'WS', 'E': 'W'},
\}

My issue was that my simple test case was picking up a perl warning as well as a Perl::Critic violation. The gutter was showing the perl warning as an error, but the bottom of the pane was displaying the Perl::Critic violation, which was pretty confusing. After getting rid of the warning, I was able to see Perl::Critic violations as warnings. There is an already open issue to deal with this in Ale, but I thought it would be helpful to post the answer here for anyone else with questions.

The main takeaway is that ale_type_map is a dict, so if you try to set it more than once, the last entry will win. The syntax above is what you want if you'd like to deal with multiple linters.

like image 192
oalders Avatar answered Nov 15 '22 04:11

oalders