Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jonasbn (1153)

jonasbn
  reversethis-{gro.napc} {ta} {nbsanoj}
http://e-diot.dk/
AOL IM: BJonasN (Add Buddy, Send Message)

Perl Programmer located in Copenhagen, Denmark. Active member of Copenhagen Perl Mongers.

Author of:

  • Business::DK::CPR
  • Business::DK::CVR
  • Business::DK::PO
  • Business::OnlinePayment::CashCow
  • Date::Holidays
  • Date::Holidays::Abstract
  • Date::Holidays::Super
  • Date::Pregnancy
  • Games::Bingo
  • Games::Bingo::Bot
  • Games::Bingo::Print
  • Module::Info::File
  • Module::Template::Setup
  • Test::Timer

and maintainer of:

  • Tie::Tools
  • XML::Conf
  • Workflow

Journal of jonasbn (1153)

Wednesday October 31, 2007
03:23 AM

Getting Started with Perl::Critic

[ #34797 ]

I gave a quick (unprepared) lightning-talk in Danglish to the Copenhagen Perl Mongers yesterday on getting started with Perl::Critic.

Well my only preparation was my experiences and existing code.

My idea was to help people kick-off their use of Perl::Critic, by adding a t/critic.t test from Test::Perl:: Critic to their project so the static code analysis performed by Perl::Critic becomes and integrated part of the build-test process.

I often resort to the following list of policies, but I always attempt to guess what policies I am looking for since I have only been using the default output.

After some discussion and POD reading, we located the -verbose flag and this could even go into the perlcriticrc in the t/ directory as:

verbose = 8

And this gives you easily identifiable policy names

So a successful evening and I learned something too.

Anyway this brings me to something related.

The perlcriticrc is located in t/ (based on the example from the POD of Test::Perl::Critic). But wouldn't it be nicer if is was located in the root directory of the given project, since then you could use it also for the command line tool and other things if necessary since the local directory is checked first for the existence of a .perlcriticrc according to the POD of Perl::Critic.

If anybody has any suggestions along these lines please let me know.

Well back to the topic

The idea of having Test::Critic integrated in you build-test process is that it lets you hack away and you do not forget to run perlcritic against you code.

Of course you still have the option of setting TEST_AUTHOR so the tests are skipped - I renamed this to TEST_CRITIC in my own tests, since this is easier to remember and I need TEST_AUTHOR for my CPAN work.

finally, to follow-up on RJBS journal entry on headless use of Perl::Critic, do not just adhere to policies because you see a violation, either disable the given policy in the local scope or in your the t/perlcriticrc and document as to why or rewrite your code accordingly.

The good thing about Perl::Critic is that it should have you thinking about your code, it is not writing your code - you are!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.