running perlcritic on legacy Perl code

I got asked “at work” to run perlcritic on some legacy Perl code, and I got flooded with complaints. So I invested a little time in finding out, how to switch certain checks off. This is my perlcritic command line:

$ perlcritic --theme=core --exclude=NamingConventions::Capitalization --exclude=ControlStructures::ProhibitPostfixControls --exclude=Documentation::RequirePodAtEnd --exclude=Subroutines::RequireArgUnpacking --exclude=Variables::ProhibitPunctuationVars ...

Using all these command line switches you can somehow restrict the endless complaints about the code in question. But that did not remove all relevant classes of complaints, so I also had to pipe resp. filter through a couple of cascaded “fgrep -v ‘…‘”.

Actually I really liked implementing some of the rules expressed in PBP (“Perl Best Practices” — and perlcritic basically is a “PBP checker”) like:

  • avoid statement modifiers
  • avoid “unless” — as soon as it’s around a non-trivial expression, it’s just getting weird

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.