NAME
criticism - Perl pragma to enforce coding standards and best-practices
SYNOPSIS
use criticism;
use criticism 'gentle';
use criticism 'stern';
use criticism 'harsh';
use criticism 'cruel';
use criticism 'brutal';
DESCRIPTION
This pragma enforces coding standards and promotes best-practices by running your file through Perl::Critic before every execution. In a production system, this usually isn't feasible because it adds a lot of overhead at start-up. If you have a separate development environment, you can effectively bypass the criticism
pragma by not installing Perl::Critic in the production environment. If Perl::Critic can't be loaded, then criticism
just fails silently.
Alternatively, the perlcritic
command-line (which is distributed with Perl::Critic) can be used to analyze your files on-demand and has some additional configuration features. And Test::Perl::Critic provides a nice interface for analyzing files during the build process.
CONFIGURATION
The import argument is a named equivalent to the numeric severity levels in Perl::Critic. For example, use criticism 'gentle';
reports only the most dangerous violations. On the other hand, use criticism 'brutal';
reports every violation. If the import argument is not defined, it defaults to 'gentle'
.
The criticism
pragma will obey whatever configurations you have set in your .perlcriticrc file. See "CONFIGURATION" in Perl::Critic for more details.
DIAGNOSTICS
Usually, the criticism
pragma fails silently. But if you set the DEBUG
environment variable to a true value or run your program under the Perl debugger, you will get a warning when criticism
fails to load Perl::Critic.
NOTES
The criticism
pragma applies to the entire file, so it is not affected by scope or package boundaries and use
-ing it multiple times will just cause it to repeatedly process the same file. There isn't a reciprocal no criticism
pragma. However, Perl::Critic does support a pseudo-pragma that directs it to overlook certain lines or blocks of code. See "BENDING THE RULES" in Perl::Critic for more details.
AUTHOR
Jeffrey Ryan Thalhammer <thaljef@cpan.org>
COPYRIGHT
Copyright (c) 2006 Jeffrey Ryan Thalhammer. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.