Tags
There are no tags for this page.
Attachments
Hackathon Chicago, Nov 10-12, 2006
Perl::Critic
Leader: Chris Dolan (Attending Saturday only)
Interested: Andy Lester
Interested: Elliot Shank
Interested: Michael R. Wolf
Perl::Critic is an extensible framework for creating and applying coding standards to Perl source code. Essentially, it is a static source code analysis engine, like lint for C. New policies are getting added to Perl::Critic all the time, and you can help your fellow Perl programmers write cleaner, safer code.
http://perlcritic.tigris.org/
Getting Started
Before the hackathon, you should download the latest Perl::Critic from our SVN repository, and install all of its prerequisites:
% cpan install Perl::Critic
% svn checkout http://perlcritic.tigris.org/svn/perlcritic/trunk perlcritic
Username: "guest"
Password: "" (blank)
How to help
You don't have to actually know Perl::Critic or PPI's internals to help out. Most of the work is writing test cases and thinking through the logic of matching Perl code.
You can (in order from easiest to hardest):
- Choose good policies to implement
- Write some positive and negative tests
- Come up the corner cases.
- Write pseudo-code and docs
- Write the PPI implementation of pseudo-code
- Hack PPI
Items to-do
Here are a few Policy ideas from our TODO list that would greatly benefit the project. Policies typically live in the Perl::Critic::Policy:: namespace.
InputOutput::ProhibitJoinedReadline - recommend "local $/ = undef" instead
RegularExpressions::ProhibitComplexRegexps - If regexp is longer than N characters/lines, recommend it be split into "qr//" pieces
TestingAndDebugging::ProhibitProlongedStrictureOverride - Make sure that the lexical scope of a "no strict" is less than N lines
Variables::ProhibitTopicChangeInListFunction - avoid things like "map {s/ /+/g} @urls". Recommend for loops instead. Oh, and try to think up a better name.
- How about ProhibitVoidMap
- That's not the same, and it's already implemented!
ValuesAndExpressions::ProhibitComplexVersion - http://rt.cpan.org/Ticket/Display.html?id=20439
Profiling
Perl::Critic can be a resource pig. Profile it and help find the hot spots.
% perl Build.PL
% ./Build
% perl -Mbib -d:DProf t/40_criticize.t
% dprofpp
Incorporate Perl::Critic rules into your projects
This is a great way to get your feet wet and understand the power, and limitations, of Perl::Critic.
You can:
- Install Perl::Critic
- Run "perlcritic -top MyModule.pm"
- Create a custom config file
- Install Test::Perl::Critic
- Add a t/perlcritic.t to your dist
Perl::Critic::Bangs
Andy Lester's set of extensions. One of them checks for variable names ending with digits, but $md5 should be OK.
Random
Andy Lester is having a problem where he runs P::C against Socialtext Open and it complains about "Capture variable used outside conditional", but that's apparently not true.
|