Grinnz / Perl-Critic-Community

Perl::Critic::Community - Community-inspired Perl::Critic policies
https://metacpan.org/pod/Perl::Critic::Community
Other
8 stars 10 forks source link

Old-style Freenode::* modules make redundant error checking #48

Closed petdance closed 2 years ago

petdance commented 2 years ago

Consider this program foo.pl:

#!/var/perl/bin/perl

use 5.010;
use strict;
use warnings;

print $a;

If I run perlcritic on it, I get two errors:

$ perlcritic -2 -verbose='%f:%l:%c %m (%p)\n'  foo.pl
foo.pl:7:7 Using $a or $b outside sort() (Community::DollarAB)
foo.pl:7:7 Using $a or $b outside sort() (Community::DollarAB)

If I then create a Dev/perlcriticrc file like so:

[-Community::DollarAB]

and rerun I get only one error:

$ perlcritic -2 -verbose='%f:%l:%c %m (%p)\n' -p Dev/perlcriticrc foo.pl
foo.pl:7:7 Using $a or $b outside sort() (Community::DollarAB)

If I add

[-Freenode::DollarAB]

to my perlcriticrc, then it runs clean.

It looks like the Freenode::DollarAB aliasing to Community::DollarAB means I now have two policies checking on my code, and that I need to silence both of them. :-(

Grinnz commented 2 years ago

The policies use different themes. This would only happen if you've enabled both themes in your config or the command line.

petdance commented 2 years ago

I don't have any themes enabled.

Grinnz commented 2 years ago

I suppose if you don't configure any themes then it will run every policy found, which is a highly unfortunate mode of operation. Regardless, the policies are working as designed.

petdance commented 2 years ago

I don't see why that would be unfortunate. I have the policies installed that matter, and I run my code against them.

Grinnz commented 2 years ago

There are several duplicates with core policies as well. The intended method of operation is listed in the synopsis; if you wish to do something more complex, it's up to you to configure what you want to run. https://metacpan.org/pod/Perl::Critic::Community

Grinnz commented 2 years ago

(there isn't really anything I could do about this even if I wanted to; any automatic method of removing the functionality of the previous policies would break currently-working workflows using them)