Alexander Simakov has created a general script for use as a pre-commit hook in Subversion integration Perl::Critic, he describes it in his blog.
Elliot have previously discouraged this in his blog, so this of course got mentioned on twitter.
Going over the documentation of: perlcritic-checker.pl in relation to Elliot’s point of view, the following stood out.
# Emergency commits: {0|1}. There are situations when you *do* need
# to commit changes bypassing all checks (e.g. emergency bug fixes).
# This featue allows you bypass Perl::Critic using “magic” prefix in
# comment message, e.g.: svn ci -m “NO CRITIC: I am in hurry” FooBar.pm
allow_emergency_commits => 1,
# Magic prefix described above can be customized:
emergency_comment_prefix => ‘NO CRITIC’,
So Alexander actually supports commits which does not necessarily live up to the local standards implemented and configured in Perl::Critic.
Whether polluting your code base for an emergency fix is a good idea, is another discussion and taking Elliot’s example:
## no critic (RegularExpressions::ProhibitEscapedMetacharacters)
Would or at least should do just as fine, I think, without having tried it out.
I treat most of my no critic statements as #TODO points, points to be revisited later. Perl::Critic to me is lot about controlling technical debt, so hooking this mechanism into Subversion is in my opinion a good idea.
Alexanders script does even support different configurations, so you could let your pre-commit policy hook be a check for the most basic things, so your code base does not get too deep in technical debt and emergency fixes become day to day business, Perl::Critic was implemented to avoid that (see also my little Perl::Critic success story)
After all Subversion and Perl::Critic are just tools to help and assist us and our colleagues as developers.
Thank you for making this review!
I am sure that community’s feedback and pragmatic criticism (like Elliot’s) can make any software better.
Well I thought Elliott was too fast on the keys and as I wrote we have just had a marvelous presentation of P::C integration with Git from a local company at a Perl Mongers meeting, so I wanted too see some more debate…
I will try to boil down some of all the feedback I read and I will write up a blog post more or add it as a response here.
One of the things I read, which could be interesting for you would be some information from Ovid via twitter (https://twitter.com/OvidPerl/status/15847192332)
Implement a feature so the committer can actually say ‘yes’ or ‘no’, to continuing, depending on P::C feedback. I see this a a variation to the ‘NO CRITIC’ prefix use.
Keep up the good work,
jonasbn