in reply to Request for Comments on Perl::Critic
Here are my thoughts on some possible additions and modifications that might be useful:
within Vim is very nice, and is easier to configure than the :grep hack I suggested earlier. I think I've already sent you my perlcritic.vim with instructions on setting it up, but if you didn't get it, let me know.:compiler perlcritic :make
I could see this being possibly implemented as a Perl::Critic::Policy::Pragma::NoCriticRequiresComments, except that the 'no critic' blocks get stripped out before the policies are applied. Not sure if there's an easy way around that.## no critic: All the bad stuff below is necessary because [...]
You could do it with a Perl::Critic::Reference class that would provide a lookup table and remove page references entirely from the Policy modules. You could look up the appropriate reference with something like:
Data files containing the explanation reference could be subclasses of Perl::Critic::Reference (with the parent delegating the ->lookup() to each of the load()'ed subclasses in order until a hit is found), or they could just be YAML files merged into a single hash for lookup.use Perl::Critic::Reference; my $ref = Perl::Critic::Reference->new(); # Load reference data for policies from three different files $ref->load( qw( PBP FooCorpCodingStyle CodeComplete ) ); # and later... my $explanation = $ref->lookup($violation->policy());
Hmm... that Reference idea sounds useful, and not too difficult. If you'd take the patch, I think I might try coding it up.
One last comment before I head off to sleep. I'm not sure I agree with the idea that Perl::Critic could or should be enhanced to correct the code. I use Perl::Critic to warn me when I'm doing something silly, so that I can fix it, and by fixing it, learn to not do it again. If it tried to correct those things for me, there's less of an opportunity to learn. Plus, some of the things detected by the policies would be downright nasty, if not impossible, to auto-correct without potentially breaking the code.
|
---|