Perl::Critic

LTjake on 2009-05-01T19:42:40

Holy -- this weekly thing goes by way too fast!

Anyway, as promised, I'm making my first QA tool post. This week, we're chatting about Perl::Critic.

Perl::Critic has been around since late 2005. I was able to resist its icy gaze until last fall. So, why wouldn't I want to jump right in with Perl::Critic early on? Mostly what I imagined was putting a significant amount of time in to bend Perl::Critic policies to my will so I wouldn't have to change how I code. This is, of course, the wrong way to look at it.

There's nothing wrong with having a tool that confirms you're doing the right thing -- but what I really wanted was a tool that showed me the bad habits I've learned and gave me a slap on the wrist every time I tried to use them. The easiest way to get started was to copy someone else's polcy file. RJBS was nice enough to comply.

For the Image::TextMode project, after adding my own tweaks to the policies, this is the result. A simple automated test integrates it into my development cycle.

After running it against my code, it found some issues -- most of my which were pretty tame: 2-arg open, lack of pod, plus a few regex and character matching niggles.

In my policy file, I have two sections: Things I don't agree with and things I've had to disable temporarily. I hope to eventually go back and clean up my code so I can remove the remainder of the temporarily disabled policies. The policies I don't agree with may change over time, but this is my current list of preferences.

I have yet to use this setup in any other project, but I think the tool is useful enough that I could put it into place from the very beginning of a project or go back and run it against all of my old projects over time.

Until next time...