.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Test::Perl::Critic::Progressive 3pm" .TH Test::Perl::Critic::Progressive 3pm "2022-06-28" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::Perl::Critic::Progressive \- Gradually enforce coding standards. .SH "SYNOPSIS" .IX Header "SYNOPSIS" To test one or more files, and/or all files in one or more directories: .PP .Vb 2 \& use Test::Perl::Critic::Progressive qw( progressive_critic_ok ); \& progressive_critic_ok($file1, $file2, $dir1, $dir2); .Ve .PP To test all Perl files in a distribution: .PP .Vb 2 \& use Test::Perl::Critic::Progressive qw( progressive_critic_ok ); \& progressive_critic_ok(); .Ve .PP Recommended usage for public \s-1CPAN\s0 distributions: .PP .Vb 3 \& use strict; \& use warnings; \& use Test::More; \& \& eval { require Test::Perl::Critic::Progressive }; \& plan skip_all => \*(AqT::P::C::Progressive required for this test\*(Aq if $@; \& \& Test::Perl::Critic::Progressive::progressive_critic_ok(); .Ve .SH "DESCRIPTION" .IX Header "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 prevent further deterioration of your code and \&\fBgradually\fR steer it towards conforming with your chosen coding standards. .PP 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, this test will fail and the build will break unless it has the same (or fewer) Perl::Critic violations than the last successful test. .PP See the \*(L"\s-1NOTES\*(R"\s0 for more details about how this test works. .SH "SUBROUTINES" .IX Header "SUBROUTINES" All of the following subroutines can be exported upon request. Or you can export all of them at once using the \f(CW\*(Aq:all\*(Aq\fR tag. .ie n .IP """ progressive_critic_ok(@FILES [, @DIRECTORIES ]) """ 4 .el .IP "\f(CW progressive_critic_ok(@FILES [, @DIRECTORIES ]) \fR" 4 .IX Item " progressive_critic_ok(@FILES [, @DIRECTORIES ]) " .PD 0 .ie n .IP """ progressive_critic_ok() """ 4 .el .IP "\f(CW progressive_critic_ok() \fR" 4 .IX Item " progressive_critic_ok() " .PD Uses Perl::Critic to analyze each of the given \f(CW@FILES\fR, and/or all Perl files beneath the given list of \f(CW@DIRECTORIES\fR. If no arguments are given, it analyzes all the Perl files in the \fIblib/\fR directory. If the \fIblib/\fR directory does not exist, then it tries the \fIlib/\fR, \fIbin/\fR, \fIscript/\fR, and \&\fIscripts/\fR directory. The results of the analysis will be stored as \&\fI.perlcritic\-history\fR in the same directory where your test script is located. .Sp The first time you run this test, it will always pass. But on each subsequent run, the test will pass only if the number of violations found \fBis less than or equal to\fR the number of violations found during the last passing test. If it does pass, then the history file will be updated with the new analysis results. Once all the violations are removed from the code, this test will always pass, unless a new violation is introduced. .Sp This subroutine emits its own Test::More plan, so you do not need to specify an expected number of tests yourself. .ie n .IP """ get_history_file() """ 4 .el .IP "\f(CW get_history_file() \fR" 4 .IX Item " get_history_file() " .PD 0 .ie n .IP """ set_history_file($FILE) """ 4 .el .IP "\f(CW set_history_file($FILE) \fR" 4 .IX Item " set_history_file($FILE) " .PD 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 \f(CW$FILE\fR does not exist, it will be created anew. The default is \f(CW\*(C`$Bin/.perlcritic\-history\*(C'\fR where \f(CW$Bin\fR is the directory that the calling test script is located in. .ie n .IP """ get_total_step_size() """ 4 .el .IP "\f(CW get_total_step_size() \fR" 4 .IX Item " get_total_step_size() " .PD 0 .ie n .IP """ set_total_step_size($INTEGER) """ 4 .el .IP "\f(CW set_total_step_size($INTEGER) \fR" 4 .IX Item " set_total_step_size($INTEGER) " .PD These functions get or set the minimum acceptable decrease in the \fBtotal\fR number of violations between each test. The default value is zero, which means that you are not required to remove any violations, but you are also not allowed to add any. If you set the step size to a positive number, the test will require you to remove \f(CW$INTEGER\fR violations each time the test is run. In this case, the particular type of violation that you eliminate doesn't matter. The larger the step size, the faster you'll have to eliminate violations. .ie n .IP """ get_step_size_per_policy() """ 4 .el .IP "\f(CW get_step_size_per_policy() \fR" 4 .IX Item " get_step_size_per_policy() " .PD 0 .ie n .IP """ set_step_size_per_policy(%ARGS) """ 4 .el .IP "\f(CW set_step_size_per_policy(%ARGS) \fR" 4 .IX Item " set_step_size_per_policy(%ARGS) " .PD These functions get or set the minimum acceptable decrease in the number of violations of a \fBspecific policy\fR between each test. The \f(CW%ARGS\fR should be \&\f(CW\*(C`$POLICY_NAME => $INTEGER\*(C'\fR pairs, like this: .Sp .Vb 5 \& my %step_sizes = ( \& \*(AqValuesAndExpressions::ProhibitLeadingZeros\*(Aq => 2, \& \*(AqVariables::ProhibitConditionalDeclarations\*(Aq => 1, \& \*(AqInputOutput::ProhibitTwoArgOpen\*(Aq => 3, \& ); \& \& set_step_size_per_policy( %step_sizes ); \& progressive_critic_ok(); .Ve .Sp The default step size for any given Policy is zero, which means that you are not required to remove any violations, but you are also not allowed to add any. But if you wish to focus on eliminating certain types of violations, then increasing the per-policy step size will force you to \fBdecrease\fR the number of violations of that particular Policy, while ignoring other types of violations. The larger the step size, the faster you'll have to eliminate violations. .ie n .IP """ get_critic_args() """ 4 .el .IP "\f(CW get_critic_args() \fR" 4 .IX Item " get_critic_args() " .PD 0 .ie n .IP """ set_critic_args(%ARGS) """ 4 .el .IP "\f(CW set_critic_args(%ARGS) \fR" 4 .IX Item " set_critic_args(%ARGS) " .PD These functions get or set the arguments given to Perl::Critic. 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. .Sp Any \f(CW%ARGS\fR given to \f(CW\*(C`set_critic_args\*(C'\fR will be passed directly into the Perl::Critic constructor. So if you have developed your code using a custom \fI.perlcriticrc\fR file, you can direct Test::Perl::Critic::Progressive to use a custom file too. .Sp .Vb 1 \& use Test::Perl::Critic::Progressive ( \*(Aq:all\*(Aq ); \& \& set_critic_args(\-profile => \*(Aqt/perlcriticrc); \& progressive_critic_ok(); .Ve .Sp Now place a copy of your own \fI.perlcriticrc\fR file in the distribution as \&\fIt/perlcriticrc\fR. Now, \f(CW\*(C`progressive_critic_ok\*(C'\fR will use this same Perl::Critic configuration. See the Perl::Critic documentation for details on the \fI.perlcriticrc\fR file format. .Sp 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: .Sp .Vb 1 \& use Test::Perl::Critic::Progressive ( \*(Aq:all\*(Aq ); \& \& set_critic_args( \-severity => 2, \-exclude => [\*(AqMixedCaseVars\*(Aq] ); \& progressive_critic_ok(); .Ve .Sp See the Perl::Critic documentation for complete details on its options and arguments. .SH "NOTES" .IX Header "NOTES" The test is evaluated in two ways. First, the number of violations for each Policy must be \fBless than or equal to\fR the number of the violations found during the last passing test, minus the step size \fBfor that Policy\fR. Second, the total number of violations must be \fBless than or equal\fR the total number of violations found during the last passing test, minus the \fBtotal\fR step size. This prevents you from simply substituting one kind of violation for another. .PP You can use the total step size and the per-policy step size at the same time. For example, you can set the total step size to 5, and set the per-policy step size for the \f(CW\*(C`TestingAndDebugging::RequireStrictures\*(C'\fR Policy to 3. In which case, you'll have to remove 5 violations between each test, but 3 of them must be violations of \f(CW\*(C`TestingAndDebugging::RequireStrictures\*(C'\fR. .PP 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. .PP If you are building a \s-1CPAN\s0 distribution, you'll want to add \&\fI^t/.perlcritic\-history$\fR to the \fI\s-1MANIFEST.SKIP\s0\fR file. And if you are using a revision control system like \s-1CVS\s0 or Subversion, you'll probably want to configure it to ignore the \fIt/.perlcritic\-history\fR file as well. .SH "BUGS" .IX Header "BUGS" If you find any bugs, please submit them to . Thanks. .SH "SEE ALSO" .IX Header "SEE ALSO" criticism .PP Perl::Critic .PP Test::Perl::Critic .PP .SH "AUTHOR" .IX Header "AUTHOR" Jeffrey Ryan Thalhammer .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2007\-2008 Jeffrey Ryan Thalhammer. All rights reserved. .PP 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 \s-1LICENSE\s0 file included with this module.