NAME Test::Perl::Critic::Progressive - Gradualy enforce coding standards SYNOPSIS To test one or more files, and/or all files in one or more directories: use Test::Perl::Critic::Progressive; progressive_critic_ok($file_1, $file_2, $dir_1, $dir_2); To test all files in a CPAN-style distribution: use Test::Perl::Critic::Progressive; progressive_critic_ok(); DESCRIPTION Applying coding standards to large amounts of legacy code is a daunting task. Often times, legacy code is so non-compliant that it seems downright impossible. But, if you consistently chip away at the problem, you will eventually succeed! Test::Perl::Critic::Progressive uses the Perl::Critic engine to gradually steer your code towards conforming with your chosen coding standards. The most effective way to use Test::Perl::Critic::Progressive is as a unit test that is run under a continuous-integration system like CruiseControl or AntHill. Each time a developer commits changes to the code, the test will fail and the build will break unless it has fewer Perl::Critic violations than the last succesfull test. SUBROUTINES progressive_critic_ok( @FILES [, @DIRECTORIES ] ) Uses Perl::Critic to analyze each of the given @FILES, and/or all Perl files beneath the given list of @DIRECTORIES. If no arguments are given, it analyzes all the Perl files in the blib/ directory. If the blib/ directory does not exist, then it tries the lib/ directory. The results of the analysis will be stored as .perlcritic-history in the same directory where your test script is located. The first time you run this test, it will always pass. But on each subsequent run, the test will pass only if the code has fewer violations that the last time that the test passed. If it does pass, then the history file will be updated with the new analysis results. This subroutine emits its own Test::More plan, so you do not need to specify an expected number of tests yourself. CONFIGURATION You can use the following functions to configure the behavior of Test::Perl::Critic::Progressive. You should use these before calling "progressive_critic_ok". Note that they are "never" exported. " Test::Perl::Critic::Progressive::get_history_file(); " " Test::Perl::Critic::Progressive::set_history_file( $FILE ); " These functions get or set the full path to the history file. This is where Test::Perl::Critic::Progressive will store the results of each passing analysis. If the $FILE does not exist, it will be created anew. The default is "$Bin/.perlcritic-history" where $Bin is the directory that the calling test script is located in. " Test::Perl::Critic::Progressive::get_step_size(); " " Test::Perl::Critic::Progressive::set_step_size( $INTEGER ); " These functions get or set the minimum accpetable decrease in the total number of violations between each test. Increasing the step size force you eliminate violations faster. $INTEGER should positive, and the default is 1. Perl::Critic itself is also highly configurable. By default, Test::Perl::Critic::Progressive invokes Perl::Critic with its default configuration. But if you have developed your code against a custom Perl::Critic configuration, you will want to configure this test to do the same. Any arguments given to the "use" pragma will be passed into the Perl::Critic constructor. So if you have developed your code using a custom .perlcriticrc file, you can direct Test::Perl::Critic::Progressive to use a custom file too. use Test::Perl::Critic::Progressive (-profile => 't/perlcriticrc'); progressive_critic_ok(); Now place a copy of your own .perlcriticrc file in the distribution as t/perlcriticrc. Then, "progressive_critic_ok" will use this same Perl::Critic configuration. See the Perl::Critic documentation for details on the .perlcriticrc file format. Any argument that is supported by the Perl::Critic constructor can be passed through this interface. For example, you can also set the minimum severity level, or include & exclude specific policies like this: use Test::Perl::Critic::Progressive (-severity => 2, -exclude => ['Postfix']); progressive_critic_ok(); See the Perl::Critic documentation for complete details on its options and arguments. NOTES The test is evaluated in two ways. First, the number of violations for each Policy must be less than or equal to the number of the violations found during the last passing test. Second, the total number of violations must be less than the total number of violations found during the last passing test. This prevents you from simply substituting one kind of violation for another. Over time, you'll probably add new Policies to your Perl::Critic setup. When Test::Perl::Critic::Progressive uses a Policy for the first time, any newly discovered violations of that Policy will not be considered in the test. However, they will be considered in subsequent tests. EXPORTS progressive_critic_ok() BUGS If you find any bugs, please submit them to . Thanks. SEE ALSO criticism Perl::Critic Test::Perl::Critic AUTHOR Jeffrey Ryan Thalhammer COPYRIGHT Copyright (c) 2005-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.