Hackathon Chicago, Nov 10-12, 2006

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.


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

  • Done!

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


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


Andy Lester's set of extensions. One of them checks for variable names ending with digits, but $md5 should be OK.


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. Featured on 3D Insider.


Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.