.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35) .\" .\" 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 "Perl::Critic::Config 3pm" .TH Perl::Critic::Config 3pm "2020-05-17" "perl v5.30.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" Perl::Critic::Config \- The final derived Perl::Critic configuration, combined from any profile file and command\-line parameters. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Perl::Critic::Config takes care of finding and processing user-preferences for Perl::Critic. The Config object defines which Policy modules will be loaded into the Perl::Critic engine and how they should be configured. You should never really need to instantiate Perl::Critic::Config directly because the Perl::Critic constructor will do it for you. .SH "INTERFACE SUPPORT" .IX Header "INTERFACE SUPPORT" This is considered to be a non-public class. Its interface is subject to change without notice. .SH "CONSTRUCTOR" .IX Header "CONSTRUCTOR" .ie n .IP """new(...)""" 4 .el .IP "\f(CWnew(...)\fR" 4 .IX Item "new(...)" Not properly documented because you shouldn't be using this. .SH "METHODS" .IX Header "METHODS" .ie n .IP """add_policy( \-policy => $policy_name, \-params => \e%param_hash )""" 4 .el .IP "\f(CWadd_policy( \-policy => $policy_name, \-params => \e%param_hash )\fR" 4 .IX Item "add_policy( -policy => $policy_name, -params => %param_hash )" Creates a Policy object and loads it into this Config. If the object cannot be instantiated, it will throw a fatal exception. Otherwise, it returns a reference to this Critic. .Sp \&\fB\-policy\fR is the name of a Perl::Critic::Policy subclass module. The \&\f(CW\*(AqPerl::Critic::Policy\*(Aq\fR portion of the name can be omitted for brevity. This argument is required. .Sp \&\fB\-params\fR is an optional reference to a hash of Policy parameters. The contents of this hash reference will be passed into to the constructor of the Policy module. See the documentation in the relevant Policy module for a description of the arguments it supports. .ie n .IP """ all_policies_enabled_or_not() """ 4 .el .IP "\f(CW all_policies_enabled_or_not() \fR" 4 .IX Item " all_policies_enabled_or_not() " Returns a list containing references to all the Policy objects that have been seen. Note that the state of these objects is not trustworthy. In particular, it is likely that some of them are not prepared to examine any documents. .ie n .IP """ policies() """ 4 .el .IP "\f(CW policies() \fR" 4 .IX Item " policies() " Returns a list containing references to all the Policy objects that have been enabled and loaded into this Config. .ie n .IP """ exclude() """ 4 .el .IP "\f(CW exclude() \fR" 4 .IX Item " exclude() " Returns the value of the \f(CW\*(C`\-exclude\*(C'\fR attribute for this Config. .ie n .IP """ include() """ 4 .el .IP "\f(CW include() \fR" 4 .IX Item " include() " Returns the value of the \f(CW\*(C`\-include\*(C'\fR attribute for this Config. .ie n .IP """ force() """ 4 .el .IP "\f(CW force() \fR" 4 .IX Item " force() " Returns the value of the \f(CW\*(C`\-force\*(C'\fR attribute for this Config. .ie n .IP """ only() """ 4 .el .IP "\f(CW only() \fR" 4 .IX Item " only() " Returns the value of the \f(CW\*(C`\-only\*(C'\fR attribute for this Config. .ie n .IP """ profile_strictness() """ 4 .el .IP "\f(CW profile_strictness() \fR" 4 .IX Item " profile_strictness() " Returns the value of the \f(CW\*(C`\-profile\-strictness\*(C'\fR attribute for this Config. .ie n .IP """ severity() """ 4 .el .IP "\f(CW severity() \fR" 4 .IX Item " severity() " Returns the value of the \f(CW\*(C`\-severity\*(C'\fR attribute for this Config. .ie n .IP """ single_policy() """ 4 .el .IP "\f(CW single_policy() \fR" 4 .IX Item " single_policy() " Returns the value of the \f(CW\*(C`\-single\-policy\*(C'\fR attribute for this Config. .ie n .IP """ theme() """ 4 .el .IP "\f(CW theme() \fR" 4 .IX Item " theme() " Returns the Perl::Critic::Theme object that was created for this Config. .ie n .IP """ top() """ 4 .el .IP "\f(CW top() \fR" 4 .IX Item " top() " Returns the value of the \f(CW\*(C`\-top\*(C'\fR attribute for this Config. .ie n .IP """ verbose() """ 4 .el .IP "\f(CW verbose() \fR" 4 .IX Item " verbose() " Returns the value of the \f(CW\*(C`\-verbose\*(C'\fR attribute for this Config. .ie n .IP """ color() """ 4 .el .IP "\f(CW color() \fR" 4 .IX Item " color() " Returns the value of the \f(CW\*(C`\-color\*(C'\fR attribute for this Config. .ie n .IP """ pager() """ 4 .el .IP "\f(CW pager() \fR" 4 .IX Item " pager() " Returns the value of the \f(CW\*(C`\-pager\*(C'\fR attribute for this Config. .ie n .IP """ unsafe_allowed() """ 4 .el .IP "\f(CW unsafe_allowed() \fR" 4 .IX Item " unsafe_allowed() " Returns the value of the \f(CW\*(C`\-allow\-unsafe\*(C'\fR attribute for this Config. .ie n .IP """ criticism_fatal() """ 4 .el .IP "\f(CW criticism_fatal() \fR" 4 .IX Item " criticism_fatal() " Returns the value of the \f(CW\*(C`\-criticism\-fatal\*(C'\fR attribute for this Config. .ie n .IP """ color_severity_highest() """ 4 .el .IP "\f(CW color_severity_highest() \fR" 4 .IX Item " color_severity_highest() " Returns the value of the \f(CW\*(C`\-color\-severity\-highest\*(C'\fR attribute for this Config. .ie n .IP """ color_severity_high() """ 4 .el .IP "\f(CW color_severity_high() \fR" 4 .IX Item " color_severity_high() " Returns the value of the \f(CW\*(C`\-color\-severity\-high\*(C'\fR attribute for this Config. .ie n .IP """ color_severity_medium() """ 4 .el .IP "\f(CW color_severity_medium() \fR" 4 .IX Item " color_severity_medium() " Returns the value of the \f(CW\*(C`\-color\-severity\-medium\*(C'\fR attribute for this Config. .ie n .IP """ color_severity_low() """ 4 .el .IP "\f(CW color_severity_low() \fR" 4 .IX Item " color_severity_low() " Returns the value of the \f(CW\*(C`\-color\-severity\-low\*(C'\fR attribute for this Config. .ie n .IP """ color_severity_lowest() """ 4 .el .IP "\f(CW color_severity_lowest() \fR" 4 .IX Item " color_severity_lowest() " Returns the value of the \f(CW\*(C`\-color\-severity\-lowest\*(C'\fR attribute for this Config. .ie n .IP """ program_extensions() """ 4 .el .IP "\f(CW program_extensions() \fR" 4 .IX Item " program_extensions() " Returns the value of the \f(CW\*(C`\-program_extensions\*(C'\fR attribute for this Config. This is an array of the file name extensions that represent program files. .ie n .IP """ program_extensions_as_regexes() """ 4 .el .IP "\f(CW program_extensions_as_regexes() \fR" 4 .IX Item " program_extensions_as_regexes() " Returns the value of the \f(CW\*(C`\-program_extensions\*(C'\fR attribute for this Config, as an array of case-sensitive regexes matching the ends of the file names that represent program files. .SH "SUBROUTINES" .IX Header "SUBROUTINES" Perl::Critic::Config has a few static subroutines that are used internally, but may be useful to you in some way. .ie n .IP """site_policy_names()""" 4 .el .IP "\f(CWsite_policy_names()\fR" 4 .IX Item "site_policy_names()" Returns a list of all the Policy modules that are currently installed in the Perl::Critic:Policy namespace. These will include modules that are distributed with Perl::Critic plus any third-party modules that have been installed. .SH "CONFIGURATION" .IX Header "CONFIGURATION" Most of the settings for Perl::Critic and each of the Policy modules can be controlled by a configuration file. The default configuration file is called \fI.perlcriticrc\fR. Perl::Critic::Config will look for this file in the current directory first, and then in your home directory. Alternatively, you can set the \f(CW\*(C`PERLCRITIC\*(C'\fR environment variable to explicitly point to a different file in another location. If none of these files exist, and the \f(CW\*(C`\-profile\*(C'\fR option is not given to the constructor, then all Policies will be loaded with their default configuration. .PP The format of the configuration file is a series of INI-style blocks that contain key-value pairs separated by '='. Comments should start with '#' and can be placed on a separate line or after the name-value pairs if you desire. .PP Default settings for Perl::Critic itself can be set \fBbefore the first named block.\fR For example, putting any or all of these at the top of your configuration file will set the default value for the corresponding Perl::Critic constructor argument. .PP .Vb 10 \& severity = 3 #Integer from 1 to 5 \& only = 1 #Zero or One \& force = 0 #Zero or One \& verbose = 4 #Integer or format spec \& top = 50 #A positive integer \& theme = risky + (pbp * security) \- cosmetic #A theme expression \& include = NamingConventions ClassHierarchies #Space\-delimited list \& exclude = Variables Modules::RequirePackage #Space\-delimited list \& color = 1 #Zero or One \& allow_unsafe = 1 #Zero or One \& color\-severity\-highest = bold red #Term::ANSIColor \& color\-severity\-high = magenta #Term::ANSIColor \& color\-severity\-medium = #no coloring \& color\-severity\-low = #no coloring \& color\-severity\-lowest = #no coloring \& program\-extensions = #Space\-delimited list .Ve .PP The remainder of the configuration file is a series of blocks like this: .PP .Vb 6 \& [Perl::Critic::Policy::Category::PolicyName] \& severity = 1 \& set_themes = foo bar \& add_themes = baz \& arg1 = value1 \& arg2 = value2 .Ve .PP \&\f(CW\*(C`Perl::Critic::Policy::Category::PolicyName\*(C'\fR is the full name of a module that implements the policy. The Policy modules distributed with Perl::Critic have been grouped into categories according to the table of contents in Damian Conway's book \fBPerl Best Practices\fR. For brevity, you can omit the \f(CW\*(AqPerl::Critic::Policy\*(Aq\fR part of the module name. .PP \&\f(CW\*(C`severity\*(C'\fR is the level of importance you wish to assign to the Policy. All Policy modules are defined with a default severity value ranging from 1 (least severe) to 5 (most severe). However, you may disagree with the default severity and choose to give it a higher or lower severity, based on your own coding philosophy. .PP The remaining key-value pairs are configuration parameters that will be passed into the constructor of that Policy. The constructors for most Policy modules do not support arguments, and those that do should have reasonable defaults. See the documentation on the appropriate Policy module for more details. .PP Instead of redefining the severity for a given Policy, you can completely disable a Policy by prepending a '\-' to the name of the module in your configuration file. In this manner, the Policy will never be loaded, regardless of the \f(CW\*(C`\-severity\*(C'\fR given to the Perl::Critic::Config constructor. .PP A simple configuration might look like this: .PP .Vb 2 \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& # I think these are really important, so always load them \& \& [TestingAndDebugging::RequireUseStrict] \& severity = 5 \& \& [TestingAndDebugging::RequireUseWarnings] \& severity = 5 \& \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& # I think these are less important, so only load when asked \& \& [Variables::ProhibitPackageVars] \& severity = 2 \& \& [ControlStructures::ProhibitPostfixControls] \& allow = if unless #My custom configuration \& severity = 2 \& \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& # Give these policies a custom theme. I can activate just \& # these policies by saying (\-theme => \*(Aqlarry + curly\*(Aq) \& \& [Modules::RequireFilenameMatchesPackage] \& add_themes = larry \& \& [TestingAndDebugging::RequireTestLables] \& add_themes = curly moe \& \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& # I do not agree with these at all, so never load them \& \& [\-NamingConventions::Capitalization] \& [\-ValuesAndExpressions::ProhibitMagicNumbers] \& \& #\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& # For all other Policies, I accept the default severity, theme \& # and other parameters, so no additional configuration is \& # required for them. .Ve .PP For additional configuration examples, see the \fIperlcriticrc\fR file that is included in this \fIt/examples\fR directory of this distribution. .SH "THE POLICIES" .IX Header "THE POLICIES" A large number of Policy modules are distributed with Perl::Critic. They are described briefly in the companion document Perl::Critic::PolicySummary and in more detail in the individual modules themselves. .SH "POLICY THEMES" .IX Header "POLICY THEMES" Each Policy is defined with one or more \*(L"themes\*(R". Themes can be used to create arbitrary groups of Policies. They are intended to provide an alternative mechanism for selecting your preferred set of Policies. For example, you may wish disable a certain subset of Policies when analyzing test programs. Conversely, you may wish to enable only a specific subset of Policies when analyzing modules. .PP The Policies that ship with Perl::Critic are have been broken into the following themes. This is just our attempt to provide some basic logical groupings. You are free to invent new themes that suit your needs. .PP .Vb 10 \& THEME DESCRIPTION \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& core All policies that ship with Perl::Critic \& pbp Policies that come directly from "Perl Best Practices" \& bugs Policies that prevent or reveal bugs \& maintenance Policies that affect the long\-term health of the code \& cosmetic Policies that only have a superficial effect \& complexity Policies that specificaly relate to code complexity \& security Policies that relate to security issues \& tests Policies that are specific to test programs .Ve .PP Say \f(CW\*(C`\`perlcritic \-list\`\*(C'\fR to get a listing of all available policies and the themes that are associated with each one. You can also change the theme for any Policy in your \fI.perlcriticrc\fR file. See the \&\*(L"\s-1CONFIGURATION\*(R"\s0 section for more information about that. .PP Using the \f(CW\*(C`\-theme\*(C'\fR option, you can combine theme names with mathematical and boolean operators to create an arbitrarily complex expression that represents a custom \*(L"set\*(R" of Policies. The following operators are supported .PP .Vb 5 \& Operator Alternative Meaning \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& * and Intersection \& \- not Difference \& + or Union .Ve .PP Operator precedence is the same as that of normal mathematics. You can also use parenthesis to enforce precedence. Here are some examples: .PP .Vb 4 \& Expression Meaning \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& pbp * bugs All policies that are "pbp" AND "bugs" \& pbp and bugs Ditto \& \& bugs + cosmetic All policies that are "bugs" OR "cosmetic" \& bugs or cosmetic Ditto \& \& pbp \- cosmetic All policies that are "pbp" BUT NOT "cosmetic" \& pbp not cosmetic Ditto \& \& \-maintenance All policies that are NOT "maintenance" \& not maintenance Ditto \& \& (pbp \- bugs) * complexity All policies that are "pbp" BUT NOT "bugs", \& AND "complexity" \& (pbp not bugs) and complexity Ditto .Ve .PP Theme names are case-insensitive. If \f(CW\*(C`\-theme\*(C'\fR is set to an empty string, then it is equivalent to the set of all Policies. A theme name that doesn't exist is equivalent to an empty set. Please See for a discussion on set theory. .SH "SEE ALSO" .IX Header "SEE ALSO" Perl::Critic::OptionsProcessor, Perl::Critic::UserProfile .SH "AUTHOR" .IX Header "AUTHOR" Jeffrey Ryan Thalhammer .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2005\-2011 Imaginative Software Systems. 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.