Perl::Critic - Automatically review your code | Perl::Critic - автоматически проверяет Ваш код History of edits
(Latest: ginnie 3 years, 3 months ago)
§ | |
The best way to do things in Perl keeps changing, just as the language and the art of programming does. The code you wrote 10 years ago might have been best practice back then, but chances are it doesn't look too good by modern standards. Package filehandles, obscure special variables, and using select to control buffering are still supported by Perl, but they're not things that should exist in modern code. | | |
Perl::Critic reads your source code and tells you what you're doing wrong. It uses Damian Conway's book Perl Best Practices as a starting point, however it's extensible enough that you can change its policies to enable, disable and customise what it complains about. | | |
Whether you're writing new code, or maintaining old code, Perl::Critic can help you avoid bad practices and even teach you new techniques you may not have known existed. | | |
Chances are, for any serious code, Perl::Critic is going to find a lot of things to complain about. To make using it easier, there are five levels of severity that you can pick from. These are: gentle, stern, harsh, cruel and brutal. | | |
Gentle turns on only the most important and worrisome errors that Perl::Critic finds. The stern severity notes all the things that Perl::Critic is pretty sure you will want to fix. | | |
The later three levels of severity get more and more picky, down to complaining about your indentation and bracing style, whether you've commented out any code, and the modifiers used on your regular expressions. | | |
It's recommended you start using Perl::Critic with gentle feedback, and proceed to the more picky levels in an incremental manner. You may not agree with all of Perl::Critic's feedback, but we'll see in a moment how we can customise it to suit our needs. | | |
| | |
The easiest way to use Perl::Critic is to play with the web interface at http://perlcritic.com/. Here you can upload your Perl file, select a severity level and see what it complains about. This is a great way to play with Perl::Critic but becomes impractical if you have lots of files you want to critique or files containing sensitive information. | | |