and maintainer of:
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.
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!