« blib/lib/Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm
↑ Summary
blib/lib/Perl/Critic.pm »
| 1 | package Perl::Critic::Config; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 40 | ▶ | use List::SomeUtils qw( any apply ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 40 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 40 | ▶ | use Perl::Critic::Exception::AggregateConfiguration; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 40 | ▶ | use Perl::Critic::Exception::Configuration; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 40 | ▶ | use Perl::Critic::Exception::Configuration::Option::Global::ParameterValue; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 40 | ▶ | use Perl::Critic::Exception::Fatal::Internal qw{ throw_internal }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 40 | ▶ | use Perl::Critic::PolicyFactory; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 40 | ▶ | use Perl::Critic::Theme qw( $RULE_INVALID_CHARACTER_REGEX cook_rule ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 40 | ▶ | use Perl::Critic::UserProfile qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 40 | use Perl::Critic::Utils qw{ | |||||||||||||||||||||||||||
| 21 | :booleans :characters :severities :internal_lookup :classification | ||||||||||||||||||||||||||||
| 22 | :data_conversion | ||||||||||||||||||||||||||||
| 23 | 40 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 40 | use Perl::Critic::Utils::Constants qw< | |||||||||||||||||||||||||||
| 25 | :profile_strictness | ||||||||||||||||||||||||||||
| 26 | $_MODULE_VERSION_TERM_ANSICOLOR | ||||||||||||||||||||||||||||
| 27 | 40 | ▶ | >; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 40 | our $VERSION = '1.150'; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 40 | Readonly::Scalar my $SINGLE_POLICY_CONFIG_KEY => 'single-policy'; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 38 | # Constructor | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | sub new { | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 280 | ▶ | my ( $class, %args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 280 | my $self = bless {}, $class; | |||||||||||||||||||||||||||
| 44 | 280 | $self->_init( %args ); | |||||||||||||||||||||||||||
| 45 | 276 | return $self; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | sub _init { | ||||||||||||||||||||||||||||
| 51 | 280 | ▶ | my ( $self, %args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=12 SCAR=24.9
| |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # -top or -theme imply that -severity is 1, unless it is already defined | ||||||||||||||||||||||||||||
| 54 | 280 | ▶ | if ( defined $args{-top} || defined $args{-theme} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $args{"-top"} or defined $args{"-theme"}
MC/DC100%2/2
defined $args{"-top"} or defined $args{"-theme"}
defined $args{"-top"}
defined $args{"-theme"}
Truth table100%3/3
A or B
A= defined $args{"-top"}B= defined $args{"-theme"}
| |||||||||||||||||||||||||||||
| 55 | 55 | ▶ | $args{-severity} ||= $SEVERITY_LOWEST; | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{"-severity"} ||= $Perl::Critic::Config::SEVERITY_LOWEST
MC/DC0%0/2
$args{"-severity"} ||= $Perl::Critic::Config::SEVERITY_LOWEST
$args{"-severity"}
$Perl::Critic::Config::SEVERITY_LOWEST
Truth table66%2/3
A ||= B
A= $args{"-severity"}B= $Perl::Critic::Config::SEVERITY_LOWEST
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 280 | my $errors = Perl::Critic::Exception::AggregateConfiguration->new(); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # Construct the UserProfile to get default options. | ||||||||||||||||||||||||||||
| 61 | 280 | my $profile_source = $args{-profile}; # Can be file path or data struct | |||||||||||||||||||||||||||
| 62 | 280 | my $profile = Perl::Critic::UserProfile->new( -profile => $profile_source ); | |||||||||||||||||||||||||||
| 63 | 280 | my $options_processor = $profile->options_processor(); | |||||||||||||||||||||||||||
| 64 | 280 | $self->{_profile} = $profile; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | $self->_validate_and_save_profile_strictness( | ||||||||||||||||||||||||||||
| 67 | 280 | $args{'-profile-strictness'}, | |||||||||||||||||||||||||||
| 68 | $errors, | ||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # If given, these options should always have a true value. | ||||||||||||||||||||||||||||
| 72 | $self->_validate_and_save_regex( | ||||||||||||||||||||||||||||
| 73 | 280 | 'include', $args{-include}, $options_processor->include(), $errors | |||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||
| 75 | $self->_validate_and_save_regex( | ||||||||||||||||||||||||||||
| 76 | 280 | 'exclude', $args{-exclude}, $options_processor->exclude(), $errors | |||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||
| 78 | $self->_validate_and_save_regex( | ||||||||||||||||||||||||||||
| 79 | $SINGLE_POLICY_CONFIG_KEY, | ||||||||||||||||||||||||||||
| 80 | 280 | $args{ qq/-$SINGLE_POLICY_CONFIG_KEY/ }, | |||||||||||||||||||||||||||
| 81 | $options_processor->single_policy(), | ||||||||||||||||||||||||||||
| 82 | $errors, | ||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||
| 84 | $self->_validate_and_save_color_severity( | ||||||||||||||||||||||||||||
| 85 | 280 | 'color_severity_highest', $args{'-color-severity-highest'}, | |||||||||||||||||||||||||||
| 86 | $options_processor->color_severity_highest(), $errors | ||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||
| 88 | $self->_validate_and_save_color_severity( | ||||||||||||||||||||||||||||
| 89 | 280 | 'color_severity_high', $args{'-color-severity-high'}, | |||||||||||||||||||||||||||
| 90 | $options_processor->color_severity_high(), $errors | ||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||
| 92 | $self->_validate_and_save_color_severity( | ||||||||||||||||||||||||||||
| 93 | 280 | 'color_severity_medium', $args{'-color-severity-medium'}, | |||||||||||||||||||||||||||
| 94 | $options_processor->color_severity_medium(), $errors | ||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||
| 96 | $self->_validate_and_save_color_severity( | ||||||||||||||||||||||||||||
| 97 | 280 | 'color_severity_low', $args{'-color-severity-low'}, | |||||||||||||||||||||||||||
| 98 | $options_processor->color_severity_low(), $errors | ||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||
| 100 | $self->_validate_and_save_color_severity( | ||||||||||||||||||||||||||||
| 101 | 280 | 'color_severity_lowest', $args{'-color-severity-lowest'}, | |||||||||||||||||||||||||||
| 102 | $options_processor->color_severity_lowest(), $errors | ||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 280 | $self->_validate_and_save_verbosity($args{-verbose}, $errors); | |||||||||||||||||||||||||||
| 106 | 280 | $self->_validate_and_save_severity($args{-severity}, $errors); | |||||||||||||||||||||||||||
| 107 | 280 | $self->_validate_and_save_top($args{-top}, $errors); | |||||||||||||||||||||||||||
| 108 | 280 | $self->_validate_and_save_theme($args{-theme}, $errors); | |||||||||||||||||||||||||||
| 109 | 280 | $self->_validate_and_save_pager($args{-pager}, $errors); | |||||||||||||||||||||||||||
| 110 | $self->_validate_and_save_program_extensions( | ||||||||||||||||||||||||||||
| 111 | 280 | $args{'-program-extensions'}, $errors); | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | # If given, these options can be true or false (but defined) | ||||||||||||||||||||||||||||
| 114 | 280 | ▶ | $self->{_force} = _boolean_to_number( $args{-force} // $options_processor->force() ); | ||||||||||||||||||||||||||
|
Condition100%3/3
$args{"-force"} // $options_processor->force
MC/DC100%2/2
$args{"-force"} // $options_processor->force
$args{"-force"}
$options_processor->force
Truth table100%3/3
A // B
A= $args{"-force"}B= $options_processor->force
| |||||||||||||||||||||||||||||
| 115 | 280 | ▶ | $self->{_only} = _boolean_to_number( $args{-only} // $options_processor->only() ); | ||||||||||||||||||||||||||
|
Condition100%3/3
$args{"-only"} // $options_processor->only
MC/DC100%2/2
$args{"-only"} // $options_processor->only
$args{"-only"}
$options_processor->only
Truth table100%3/3
A // B
A= $args{"-only"}B= $options_processor->only
| |||||||||||||||||||||||||||||
| 116 | 280 | ▶ | $self->{_color} = _boolean_to_number( $args{-color} // $options_processor->color() ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{"-color"} // $options_processor->color
MC/DC50%1/2
$args{"-color"} // $options_processor->color
$args{"-color"}
$options_processor->color
Truth table66%2/3
A // B
A= $args{"-color"}B= $options_processor->color
| |||||||||||||||||||||||||||||
| 117 | $self->{_unsafe_allowed} = | ||||||||||||||||||||||||||||
| 118 | 280 | ▶ | _boolean_to_number( $args{'-allow-unsafe'} // $options_processor->allow_unsafe() ); | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{"-allow-unsafe"} // $options_processor->allow_unsafe
MC/DC50%1/2
$args{"-allow-unsafe"} // $options_processor->allow_unsafe
$args{"-allow-unsafe"}
$options_processor->allow_unsafe
Truth table66%2/3
A // B
A= $args{"-allow-unsafe"}B= $options_processor->allow_unsafe
| |||||||||||||||||||||||||||||
| 119 | $self->{_criticism_fatal} = | ||||||||||||||||||||||||||||
| 120 | _boolean_to_number( | ||||||||||||||||||||||||||||
| 121 | 280 | ▶ | $args{'-criticism-fatal'} // $options_processor->criticism_fatal() | ||||||||||||||||||||||||||
|
Condition66%2/3
$args{"-criticism-fatal"} // $options_processor->criticism_fatal
MC/DC50%1/2
$args{"-criticism-fatal"} // $options_processor->criticism_fatal
$args{"-criticism-fatal"}
$options_processor->criticism_fatal
Truth table66%2/3
A // B
A= $args{"-criticism-fatal"}B= $options_processor->criticism_fatal
| |||||||||||||||||||||||||||||
| 122 | ); | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | # Construct a Factory with the Profile | ||||||||||||||||||||||||||||
| 126 | 280 | my $factory = | |||||||||||||||||||||||||||
| 127 | Perl::Critic::PolicyFactory->new( | ||||||||||||||||||||||||||||
| 128 | -profile => $profile, | ||||||||||||||||||||||||||||
| 129 | -errors => $errors, | ||||||||||||||||||||||||||||
| 130 | '-profile-strictness' => $self->profile_strictness(), | ||||||||||||||||||||||||||||
| 131 | ); | ||||||||||||||||||||||||||||
| 132 | 280 | $self->{_factory} = $factory; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | # Initialize internal storage for Policies | ||||||||||||||||||||||||||||
| 135 | 280 | $self->{_all_policies_enabled_or_not} = []; | |||||||||||||||||||||||||||
| 136 | 280 | $self->{_policies} = []; | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | # "NONE" means don't load any policies | ||||||||||||||||||||||||||||
| 139 | 280 | ▶ | if ( not defined $profile_source or $profile_source ne 'NONE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $profile_source or $profile_source ne "NONE"
MC/DC100%2/2
not defined $profile_source or $profile_source ne "NONE"
not defined $profile_source
$profile_source ne "NONE"
Truth table100%3/3
not(A) or B
A= not defined $profile_sourceB= $profile_source ne "NONE"
| |||||||||||||||||||||||||||||
| 140 | # Heavy lifting here... | ||||||||||||||||||||||||||||
| 141 | 82 | $self->_load_policies($errors); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 280 | ▶ | if ( $errors->has_exceptions() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 4 | $errors->rethrow(); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 276 | return $self; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | sub _boolean_to_number { ## no critic (RequireArgUnpacking) | ||||||||||||||||||||||||||||
| 154 | 1400 | ▶ | return $_[0] ? $TRUE : $FALSE; | ||||||||||||||||||||||||||
|
Subroutine
_boolean_to_number: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub add_policy { | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 8044 | ▶ | my ( $self, %args ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
add_policy: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 8044 | ▶ | if ( not $args{-policy} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | 1 | throw_internal q{The -policy argument is required}; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 8043 | my $policy = $args{-policy}; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # If the -policy is already a blessed object, then just add it directly. | ||||||||||||||||||||||||||||
| 170 | 8043 | ▶ | if ( blessed $policy ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | 7887 | $self->_add_policy_if_enabled($policy); | |||||||||||||||||||||||||||
| 172 | 7887 | return $self; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | # NOTE: The "-config" option is supported for backward compatibility. | ||||||||||||||||||||||||||||
| 176 | 156 | ▶ | my $params = $args{-params} || $args{-config}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$args{'-params'} || $args{'-config'}
MC/DC100%2/2
$args{'-params'} || $args{'-config'}
$args{'-params'}
$args{'-config'}
Truth table100%3/3
A || B
A= $args{'-params'}B= $args{'-config'}
| |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 156 | my $factory = $self->{_factory}; | |||||||||||||||||||||||||||
| 179 | 156 | my $policy_object = | |||||||||||||||||||||||||||
| 180 | $factory->create_policy(-name=>$policy, -params=>$params); | ||||||||||||||||||||||||||||
| 181 | 155 | $self->_add_policy_if_enabled($policy_object); | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 155 | return $self; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | sub _add_policy_if_enabled { | ||||||||||||||||||||||||||||
| 189 | 8042 | ▶ | my ( $self, $policy_object ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_add_policy_if_enabled: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 8042 | ▶ | my $config = $policy_object->__get_config() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | or throw_internal | ||||||||||||||||||||||||||||
| 193 | q{Policy was not set up properly because it does not have } | ||||||||||||||||||||||||||||
| 194 | . q{a value for its config attribute.}; | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 8042 | push @{ $self->{_all_policies_enabled_or_not} }, $policy_object; | |||||||||||||||||||||||||||
| 197 | 8042 | ▶ | if ( $policy_object->initialize_if_enabled( $config ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 7944 | $policy_object->__set_enabled($TRUE); | |||||||||||||||||||||||||||
| 199 | 7944 | push @{ $self->{_policies} }, $policy_object; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | else { | ||||||||||||||||||||||||||||
| 202 | 98 | $policy_object->__set_enabled($FALSE); | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 8042 | return; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | sub _load_policies { | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 82 | ▶ | my ( $self, $errors ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_load_policies: called CC=17 SCAR=28.3
| |||||||||||||||||||||||||||||
| 213 | 82 | my $factory = $self->{_factory}; | |||||||||||||||||||||||||||
| 214 | 82 | my @policies = $factory->create_all_policies( $errors ); | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 82 | ▶ | return if $errors->has_exceptions(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 80 | for my $policy ( @policies ) { | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | # If -single-policy is true, only load policies that match it | ||||||||||||||||||||||||||||
| 221 | 11600 | ▶ | if ( $self->single_policy() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 580 | ▶ | if ( $self->_policy_is_single_policy( $policy ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 147 | $self->add_policy( -policy => $policy ); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | 580 | next; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | # Always exclude unsafe policies, unless instructed not to | ||||||||||||||||||||||||||||
| 229 | 11020 | ▶ | next if not ( $policy->is_safe() or $self->unsafe_allowed() ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$policy->is_safe or $self->unsafe_allowed
MC/DC100%2/2
$policy->is_safe or $self->unsafe_allowed
$policy->is_safe
$self->unsafe_allowed
Truth table100%3/3
A or B
A= $policy->is_safeB= $self->unsafe_allowed
| |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | # To load, or not to load -- that is the question. | ||||||||||||||||||||||||||||
| 232 | 11019 | ▶ | my $load_me = $self->only() ? $FALSE : $TRUE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | ## no critic (ProhibitPostfixControls) | ||||||||||||||||||||||||||||
| 235 | 11019 | ▶ | $load_me = $FALSE if $self->_policy_is_disabled( $policy ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 11019 | ▶ | $load_me = $TRUE if $self->_policy_is_enabled( $policy ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 237 | 11019 | ▶ | $load_me = $FALSE if $self->_policy_is_unimportant( $policy ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 11019 | ▶ | $load_me = $FALSE if not $self->_policy_is_thematic( $policy ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | 11019 | ▶ | $load_me = $TRUE if $self->_policy_is_included( $policy ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | 11019 | ▶ | $load_me = $FALSE if $self->_policy_is_excluded( $policy ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 11019 | ▶ | next if not $load_me; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 7740 | $self->add_policy( -policy => $policy ); | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | # When using -single-policy, only one policy should ever be loaded. | ||||||||||||||||||||||||||||
| 248 | 80 | ▶ | if ($self->single_policy() && scalar $self->policies() != 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->single_policy and scalar $self->policies != 1
MC/DC100%2/2
$self->single_policy and scalar $self->policies != 1
$self->single_policy
scalar $self->policies != 1
Truth table100%3/3
A and B
A= $self->single_policyB= scalar $self->policies != 1
| |||||||||||||||||||||||||||||
| 249 | 2 | $self->_add_single_policy_exception_to($errors); | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 80 | return; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | sub _policy_is_disabled { | ||||||||||||||||||||||||||||
| 258 | 11019 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_disabled: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 259 | 11019 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 260 | 11019 | return $profile->policy_is_disabled( $policy ); | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | sub _policy_is_enabled { | ||||||||||||||||||||||||||||
| 266 | 11019 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_enabled: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 267 | 11019 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 268 | 11019 | return $profile->policy_is_enabled( $policy ); | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | sub _policy_is_thematic { | ||||||||||||||||||||||||||||
| 274 | 11019 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_thematic: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 275 | 11019 | my $theme = $self->theme(); | |||||||||||||||||||||||||||
| 276 | 11019 | return $theme->policy_is_thematic( -policy => $policy ); | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | sub _policy_is_unimportant { | ||||||||||||||||||||||||||||
| 282 | 11019 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_unimportant: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 283 | 11019 | my $policy_severity = $policy->get_severity(); | |||||||||||||||||||||||||||
| 284 | 11019 | my $min_severity = $self->{_severity}; | |||||||||||||||||||||||||||
| 285 | 11019 | return $policy_severity < $min_severity; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | sub _policy_is_included { | ||||||||||||||||||||||||||||
| 291 | 11019 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_included: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 292 | 11019 | my $policy_long_name = ref $policy; | |||||||||||||||||||||||||||
| 293 | 11019 | my @inclusions = $self->include(); | |||||||||||||||||||||||||||
| 294 | 11019 | ▶ | return any { $policy_long_name =~ m/$_/ixms } @inclusions; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | sub _policy_is_excluded { | ||||||||||||||||||||||||||||
| 300 | 11019 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_excluded: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 301 | 11019 | my $policy_long_name = ref $policy; | |||||||||||||||||||||||||||
| 302 | 11019 | my @exclusions = $self->exclude(); | |||||||||||||||||||||||||||
| 303 | 11019 | ▶ | return any { $policy_long_name =~ m/$_/ixms } @exclusions; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | sub _policy_is_single_policy { | ||||||||||||||||||||||||||||
| 309 | 580 | ▶ | my ($self, $policy) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_policy_is_single_policy: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 580 | my @patterns = $self->single_policy(); | |||||||||||||||||||||||||||
| 312 | 580 | ▶ | return if not @patterns; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 580 | my $policy_long_name = ref $policy; | |||||||||||||||||||||||||||
| 315 | 580 | ▶ | return any { $policy_long_name =~ m/$_/ixms } @patterns; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | sub _new_global_value_exception { | ||||||||||||||||||||||||||||
| 321 | 16 | ▶ | my ($self, @args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_new_global_value_exception: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | return | ||||||||||||||||||||||||||||
| 324 | 16 | Perl::Critic::Exception::Configuration::Option::Global::ParameterValue | |||||||||||||||||||||||||||
| 325 | ->new(@args); | ||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | sub _add_single_policy_exception_to { | ||||||||||||||||||||||||||||
| 331 | 2 | ▶ | my ($self, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_add_single_policy_exception_to: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 2 | my $message_suffix = $EMPTY; | |||||||||||||||||||||||||||
| 334 | 2 | my $patterns = join q{", "}, $self->single_policy(); | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 2 | ▶ | if (scalar $self->policies() == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 1 | $message_suffix = | |||||||||||||||||||||||||||
| 338 | q{did not match any policies (in combination with } | ||||||||||||||||||||||||||||
| 339 | . q{other policy restrictions).}; | ||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||
| 342 | 1 | $message_suffix = qq{matched multiple policies:\n\t}; | |||||||||||||||||||||||||||
| 343 | 1 | ▶ | $message_suffix .= join qq{,\n\t}, apply { chomp } sort $self->policies(); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 2 | $errors->add_exception( | |||||||||||||||||||||||||||
| 347 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 348 | option_name => $SINGLE_POLICY_CONFIG_KEY, | ||||||||||||||||||||||||||||
| 349 | option_value => $patterns, | ||||||||||||||||||||||||||||
| 350 | message_suffix => $message_suffix, | ||||||||||||||||||||||||||||
| 351 | ) | ||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 2 | return; | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | sub _validate_and_save_regex { | ||||||||||||||||||||||||||||
| 360 | 840 | ▶ | my ($self, $option_name, $args_value, $default_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_regex: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 840 | my $full_option_name; | |||||||||||||||||||||||||||
| 363 | my $source; | ||||||||||||||||||||||||||||
| 364 | 840 | my @regexes; | |||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 840 | ▶ | if ($args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 8 | $full_option_name = "-$option_name"; | |||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 8 | ▶ | if (ref $args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 370 | 4 | @regexes = @{ $args_value }; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | else { | ||||||||||||||||||||||||||||
| 373 | 4 | @regexes = ( $args_value ); | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 840 | ▶ | if (not @regexes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 378 | 832 | $full_option_name = $option_name; | |||||||||||||||||||||||||||
| 379 | 832 | $source = $self->_profile()->source(); | |||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | 832 | ▶ | if (ref $default_value) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 382 | 556 | @regexes = @{ $default_value }; | |||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||
| 384 | elsif ($default_value) { | ||||||||||||||||||||||||||||
| 385 | 1 | @regexes = ( $default_value ); | |||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 840 | my $found_errors; | |||||||||||||||||||||||||||
| 390 | 840 | foreach my $regex (@regexes) { | |||||||||||||||||||||||||||
| 391 | 18 | eval { qr/$regex/ixms } | |||||||||||||||||||||||||||
| 392 | 18 | ▶ | or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 3 | ▶ | my $cleaned_error = $EVAL_ERROR || '<unknown reason>'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Perl::Critic::Config::EVAL_ERROR || '<unknown reason>'
MC/DC0%0/1
$Perl::Critic::Config::EVAL_ERROR || '<unknown reason>'
$Perl::Critic::Config::EVAL_ERROR
Truth table50%1/2
A
A= $Perl::Critic::Config::EVAL_ERROR
| |||||||||||||||||||||||||||||
| 394 | 3 | $cleaned_error =~ | |||||||||||||||||||||||||||
| 395 | s/ [ ] at [ ] .* Config [.] pm [ ] line [ ] \d+ [.] \n? \z/./xms; | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 3 | $errors->add_exception( | |||||||||||||||||||||||||||
| 398 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 399 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 400 | option_value => $regex, | ||||||||||||||||||||||||||||
| 401 | source => $source, | ||||||||||||||||||||||||||||
| 402 | message_suffix => qq{is not valid: $cleaned_error}, | ||||||||||||||||||||||||||||
| 403 | ) | ||||||||||||||||||||||||||||
| 404 | ); | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 3 | $found_errors = 1; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 840 | ▶ | if (not $found_errors) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 411 | 837 | my $option_key = $option_name; | |||||||||||||||||||||||||||
| 412 | 837 | $option_key =~ s/ - /_/xmsg; | |||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 837 | $self->{"_$option_key"} = \@regexes; | |||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 840 | return; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | sub _validate_and_save_profile_strictness { | ||||||||||||||||||||||||||||
| 423 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_profile_strictness: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 280 | my $option_name; | |||||||||||||||||||||||||||
| 426 | my $source; | ||||||||||||||||||||||||||||
| 427 | 280 | my $profile_strictness; | |||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 280 | ▶ | if ($args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 430 | 0 | $option_name = '-profile-strictness'; | |||||||||||||||||||||||||||
| 431 | 0 | $profile_strictness = $args_value; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | else { | ||||||||||||||||||||||||||||
| 434 | 280 | $option_name = 'profile-strictness'; | |||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | 280 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 437 | 280 | $source = $profile->source(); | |||||||||||||||||||||||||||
| 438 | 280 | $profile_strictness = $profile->options_processor()->profile_strictness(); | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 280 | ▶ | if ( not $PROFILE_STRICTNESSES{$profile_strictness} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 442 | 1 | $errors->add_exception( | |||||||||||||||||||||||||||
| 443 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 444 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 445 | option_value => $profile_strictness, | ||||||||||||||||||||||||||||
| 446 | source => $source, | ||||||||||||||||||||||||||||
| 447 | message_suffix => q{is not one of "} | ||||||||||||||||||||||||||||
| 448 | . join ( q{", "}, (sort keys %PROFILE_STRICTNESSES) ) | ||||||||||||||||||||||||||||
| 449 | . q{".}, | ||||||||||||||||||||||||||||
| 450 | ) | ||||||||||||||||||||||||||||
| 451 | ); | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 1 | $profile_strictness = $PROFILE_STRICTNESS_FATAL; | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 280 | $self->{_profile_strictness} = $profile_strictness; | |||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | 280 | return; | |||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | sub _validate_and_save_verbosity { | ||||||||||||||||||||||||||||
| 464 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_verbosity: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | 280 | my $option_name; | |||||||||||||||||||||||||||
| 467 | my $source; | ||||||||||||||||||||||||||||
| 468 | 280 | my $verbosity; | |||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 280 | ▶ | if ($args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | 0 | $option_name = '-verbose'; | |||||||||||||||||||||||||||
| 472 | 0 | $verbosity = $args_value; | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | else { | ||||||||||||||||||||||||||||
| 475 | 280 | $option_name = 'verbose'; | |||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 280 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 478 | 280 | $source = $profile->source(); | |||||||||||||||||||||||||||
| 479 | 280 | $verbosity = $profile->options_processor()->verbose(); | |||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | 280 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
is_integer($verbosity) and not is_valid_numeric_verbosity($verbosity)
MC/DC50%1/2
is_integer($verbosity) and not is_valid_numeric_verbosity($verbosity)
is_integer($verbosity)
not is_valid_numeric_verbosity($verbosity)
Truth table66%2/3
A and not(B)
A= is_integer($verbosity)B= not is_valid_numeric_verbosity($verbosity)
| |||||||||||||||||||||||||||||
| 483 | is_integer($verbosity) | ||||||||||||||||||||||||||||
| 484 | and not is_valid_numeric_verbosity($verbosity) | ||||||||||||||||||||||||||||
| 485 | ) { | ||||||||||||||||||||||||||||
| 486 | 1 | $errors->add_exception( | |||||||||||||||||||||||||||
| 487 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 488 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 489 | option_value => $verbosity, | ||||||||||||||||||||||||||||
| 490 | source => $source, | ||||||||||||||||||||||||||||
| 491 | message_suffix => | ||||||||||||||||||||||||||||
| 492 | 'is not the number of one of the pre-defined verbosity formats.', | ||||||||||||||||||||||||||||
| 493 | ) | ||||||||||||||||||||||||||||
| 494 | ); | ||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||
| 496 | else { | ||||||||||||||||||||||||||||
| 497 | 279 | $self->{_verbose} = $verbosity; | |||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||
| 500 | 280 | return; | |||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | sub _validate_and_save_severity { | ||||||||||||||||||||||||||||
| 506 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_severity: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 280 | my $option_name; | |||||||||||||||||||||||||||
| 509 | my $source; | ||||||||||||||||||||||||||||
| 510 | 280 | my $severity; | |||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 280 | ▶ | if ($args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 513 | 68 | $option_name = '-severity'; | |||||||||||||||||||||||||||
| 514 | 68 | $severity = $args_value; | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | else { | ||||||||||||||||||||||||||||
| 517 | 212 | $option_name = 'severity'; | |||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | 212 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 520 | 212 | $source = $profile->source(); | |||||||||||||||||||||||||||
| 521 | 212 | $severity = $profile->options_processor()->severity(); | |||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||
| 524 | 280 | ▶ | if ( is_integer($severity) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 525 | 274 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$severity >= $Perl::Critic::Config::SEVERITY_LOWEST and $severity <= $Perl::Critic::Config::SEVERITY_HIGHEST
MC/DC50%1/2
$severity >= $Perl::Critic::Config::SEVERITY_LOWEST and $severity <= $Perl::Critic::Config::SEVERITY_HIGHEST
$severity >= $Perl::Critic::Config::SEVERITY_LOWEST
$severity <= $Perl::Critic::Config::SEVERITY_HIGHEST
Truth table66%2/3
A and B
A= $severity >= $Perl::Critic::Config::SEVERITY_LOWESTB= $severity <= $Perl::Critic::Config::SEVERITY_HIGHEST
| |||||||||||||||||||||||||||||
| 526 | $severity >= $SEVERITY_LOWEST and $severity <= $SEVERITY_HIGHEST | ||||||||||||||||||||||||||||
| 527 | ) { | ||||||||||||||||||||||||||||
| 528 | 273 | $self->{_severity} = $severity; | |||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||
| 530 | else { | ||||||||||||||||||||||||||||
| 531 | 1 | $errors->add_exception( | |||||||||||||||||||||||||||
| 532 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 533 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 534 | option_value => $severity, | ||||||||||||||||||||||||||||
| 535 | source => $source, | ||||||||||||||||||||||||||||
| 536 | message_suffix => | ||||||||||||||||||||||||||||
| 537 | "is not between $SEVERITY_LOWEST (low) and $SEVERITY_HIGHEST (high).", | ||||||||||||||||||||||||||||
| 538 | ) | ||||||||||||||||||||||||||||
| 539 | ); | ||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||
| 542 | 20 | ▶ | elsif ( not any { $_ eq lc $severity } @SEVERITY_NAMES ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 543 | 1 | $errors->add_exception( | |||||||||||||||||||||||||||
| 544 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 545 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 546 | option_value => $severity, | ||||||||||||||||||||||||||||
| 547 | source => $source, | ||||||||||||||||||||||||||||
| 548 | message_suffix => | ||||||||||||||||||||||||||||
| 549 | q{is not one of the valid severity names: "} | ||||||||||||||||||||||||||||
| 550 | . join (q{", "}, @SEVERITY_NAMES) | ||||||||||||||||||||||||||||
| 551 | . q{".}, | ||||||||||||||||||||||||||||
| 552 | ) | ||||||||||||||||||||||||||||
| 553 | ); | ||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||
| 555 | else { | ||||||||||||||||||||||||||||
| 556 | 5 | $self->{_severity} = severity_to_number($severity); | |||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 280 | return; | |||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | sub _validate_and_save_top { | ||||||||||||||||||||||||||||
| 565 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_top: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||
| 567 | 280 | my $option_name; | |||||||||||||||||||||||||||
| 568 | my $source; | ||||||||||||||||||||||||||||
| 569 | 280 | my $top; | |||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 280 | ▶ | if (defined $args_value and $args_value ne q{}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $args_value and $args_value ne ""
MC/DC100%2/2
defined $args_value and $args_value ne ""
defined $args_value
$args_value ne ""
Truth table100%3/3
A and B
A= defined $args_valueB= $args_value ne ""
| |||||||||||||||||||||||||||||
| 572 | 2 | $option_name = '-top'; | |||||||||||||||||||||||||||
| 573 | 2 | $top = $args_value; | |||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||
| 575 | else { | ||||||||||||||||||||||||||||
| 576 | 278 | $option_name = 'top'; | |||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | 278 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 579 | 278 | $source = $profile->source(); | |||||||||||||||||||||||||||
| 580 | 278 | $top = $profile->options_processor()->top(); | |||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | 280 | ▶ | if ( is_integer($top) and $top >= 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
is_integer($top) and $top >= 0
MC/DC50%1/2
is_integer($top) and $top >= 0
is_integer($top)
$top >= 0
Truth table66%2/3
A and B
A= is_integer($top)B= $top >= 0
| |||||||||||||||||||||||||||||
| 584 | 279 | $self->{_top} = $top; | |||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||
| 586 | else { | ||||||||||||||||||||||||||||
| 587 | 1 | $errors->add_exception( | |||||||||||||||||||||||||||
| 588 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 589 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 590 | option_value => $top, | ||||||||||||||||||||||||||||
| 591 | source => $source, | ||||||||||||||||||||||||||||
| 592 | message_suffix => q{is not a non-negative integer.}, | ||||||||||||||||||||||||||||
| 593 | ) | ||||||||||||||||||||||||||||
| 594 | ); | ||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | 280 | return; | |||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | sub _validate_and_save_theme { | ||||||||||||||||||||||||||||
| 603 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_theme: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||
| 605 | 280 | my $option_name; | |||||||||||||||||||||||||||
| 606 | my $source; | ||||||||||||||||||||||||||||
| 607 | 280 | my $theme_rule; | |||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | 280 | ▶ | if ($args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 610 | 52 | $option_name = '-theme'; | |||||||||||||||||||||||||||
| 611 | 52 | $theme_rule = $args_value; | |||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||
| 613 | else { | ||||||||||||||||||||||||||||
| 614 | 228 | $option_name = 'theme'; | |||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | 228 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 617 | 228 | $source = $profile->source(); | |||||||||||||||||||||||||||
| 618 | 228 | $theme_rule = $profile->options_processor()->theme(); | |||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | 280 | ▶ | if ( $theme_rule =~ m/$RULE_INVALID_CHARACTER_REGEX/xms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 622 | 0 | my $bad_character = $1; | |||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | 0 | $errors->add_exception( | |||||||||||||||||||||||||||
| 625 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 626 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 627 | option_value => $theme_rule, | ||||||||||||||||||||||||||||
| 628 | source => $source, | ||||||||||||||||||||||||||||
| 629 | message_suffix => | ||||||||||||||||||||||||||||
| 630 | qq{contains an illegal character ("$bad_character").}, | ||||||||||||||||||||||||||||
| 631 | ) | ||||||||||||||||||||||||||||
| 632 | ); | ||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||
| 634 | else { | ||||||||||||||||||||||||||||
| 635 | 280 | my $rule_as_code = cook_rule($theme_rule); | |||||||||||||||||||||||||||
| 636 | 280 | $rule_as_code =~ s/ [\w\d]+ / 1 /gxms; | |||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | # eval of an empty string does not reset $@ in Perl 5.6. | ||||||||||||||||||||||||||||
| 639 | 280 | local $EVAL_ERROR = $EMPTY; | |||||||||||||||||||||||||||
| 640 | 280 | eval $rule_as_code; ## no critic (ProhibitStringyEval, RequireCheckingReturnValueOfEval) | |||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | 280 | ▶ | if ($EVAL_ERROR) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 643 | 1 | $errors->add_exception( | |||||||||||||||||||||||||||
| 644 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 645 | option_name => $option_name, | ||||||||||||||||||||||||||||
| 646 | option_value => $theme_rule, | ||||||||||||||||||||||||||||
| 647 | source => $source, | ||||||||||||||||||||||||||||
| 648 | message_suffix => q{is not syntactically valid.}, | ||||||||||||||||||||||||||||
| 649 | ) | ||||||||||||||||||||||||||||
| 650 | ); | ||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||
| 652 | else { | ||||||||||||||||||||||||||||
| 653 | eval { | ||||||||||||||||||||||||||||
| 654 | $self->{_theme} = | ||||||||||||||||||||||||||||
| 655 | 279 | Perl::Critic::Theme->new( -rule => $theme_rule ); | |||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||
| 657 | 279 | ▶ | or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 658 | 0 | $errors->add_exception_or_rethrow( $EVAL_ERROR ); | |||||||||||||||||||||||||||
| 659 | }; | ||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||
| 663 | 280 | return; | |||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | sub _validate_and_save_pager { | ||||||||||||||||||||||||||||
| 669 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_pager: called CC=5 SCAR=18.5
| |||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | 280 | my $pager; | |||||||||||||||||||||||||||
| 672 | 280 | ▶ | if ( $args_value ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 673 | 0 | $pager = $args_value; | |||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||
| 675 | elsif ( $ENV{PERLCRITIC_PAGER} ) { | ||||||||||||||||||||||||||||
| 676 | 0 | $pager = $ENV{PERLCRITIC_PAGER}; | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | else { | ||||||||||||||||||||||||||||
| 679 | 280 | my $profile = $self->_profile(); | |||||||||||||||||||||||||||
| 680 | 280 | $pager = $profile->options_processor()->pager(); | |||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | 280 | ▶ | if ($pager eq '$PAGER') { ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 684 | 0 | $pager = $ENV{PAGER}; | |||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||
| 686 | 280 | ▶ | $pager ||= $EMPTY; | ||||||||||||||||||||||||||
|
Condition33%1/3
$pager ||= $Perl::Critic::Config::EMPTY
MC/DC0%0/2
$pager ||= $Perl::Critic::Config::EMPTY
$pager
$Perl::Critic::Config::EMPTY
Truth table33%1/3
A ||= B
A= $pagerB= $Perl::Critic::Config::EMPTY
| |||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||
| 688 | 280 | $self->{_pager} = $pager; | |||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | 280 | return; | |||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | sub _validate_and_save_color_severity { | ||||||||||||||||||||||||||||
| 696 | 1400 | ▶ | my ($self, $option_name, $args_value, $default_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_color_severity: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | 1400 | my $source; | |||||||||||||||||||||||||||
| 699 | my $color_severity; | ||||||||||||||||||||||||||||
| 700 | 1400 | my $full_option_name; | |||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | 1400 | ▶ | if (defined $args_value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 703 | 5 | $full_option_name = "-$option_name"; | |||||||||||||||||||||||||||
| 704 | 5 | $color_severity = lc $args_value; | |||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||
| 706 | else { | ||||||||||||||||||||||||||||
| 707 | 1395 | $full_option_name = $option_name; | |||||||||||||||||||||||||||
| 708 | 1395 | $source = $self->_profile()->source(); | |||||||||||||||||||||||||||
| 709 | 1395 | $color_severity = lc $default_value; | |||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||
| 711 | 1400 | $color_severity =~ s/ \s+ / /xmsg; | |||||||||||||||||||||||||||
| 712 | 1400 | $color_severity =~ s/ \A\s+ //xms; | |||||||||||||||||||||||||||
| 713 | 1400 | $color_severity =~ s/ \s+\z //xms; | |||||||||||||||||||||||||||
| 714 | 1400 | $full_option_name =~ s/ _ /-/xmsg; | |||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||
| 716 | # Should we really be validating this? | ||||||||||||||||||||||||||||
| 717 | 1400 | my $found_errors; | |||||||||||||||||||||||||||
| 718 | 1400 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 719 | eval { | ||||||||||||||||||||||||||||
| 720 | 1400 | require Term::ANSIColor; | |||||||||||||||||||||||||||
| 721 | 1400 | Term::ANSIColor->VERSION( $_MODULE_VERSION_TERM_ANSICOLOR ); | |||||||||||||||||||||||||||
| 722 | 1400 | 1; | |||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||
| 724 | ) { | ||||||||||||||||||||||||||||
| 725 | 1400 | $found_errors = | |||||||||||||||||||||||||||
| 726 | not Term::ANSIColor::colorvalid( words_from_string($color_severity) ); | ||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||
| 729 | # If we do not have Term::ANSIColor we can not validate, but we store the | ||||||||||||||||||||||||||||
| 730 | # values anyway for the benefit of Perl::Critic::ProfilePrototype. | ||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||
| 732 | 1400 | ▶ | if ($found_errors) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 733 | 5 | $errors->add_exception( | |||||||||||||||||||||||||||
| 734 | $self->_new_global_value_exception( | ||||||||||||||||||||||||||||
| 735 | option_name => $full_option_name, | ||||||||||||||||||||||||||||
| 736 | option_value => $color_severity, | ||||||||||||||||||||||||||||
| 737 | source => $source, | ||||||||||||||||||||||||||||
| 738 | message_suffix => 'is not valid.', | ||||||||||||||||||||||||||||
| 739 | ) | ||||||||||||||||||||||||||||
| 740 | ); | ||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||
| 742 | else { | ||||||||||||||||||||||||||||
| 743 | 1395 | my $option_key = $option_name; | |||||||||||||||||||||||||||
| 744 | 1395 | $option_key =~ s/ - /_/xmsg; | |||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | 1395 | $self->{"_$option_key"} = $color_severity; | |||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | 1400 | return; | |||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||
| 752 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||
| 754 | sub _validate_and_save_program_extensions { | ||||||||||||||||||||||||||||
| 755 | 280 | ▶ | my ($self, $args_value, $errors) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_validate_and_save_program_extensions: called CC=2 SCAR=7.3
| |||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | 280 | delete $self->{_program_extensions_as_regexes}; | |||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | my $extension_list = q{ARRAY} eq ref $args_value ? | ||||||||||||||||||||||||||||
| 760 | 280 | ▶ | [map {words_from_string($_)} @{ $args_value }] : | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 761 | $self->_profile()->options_processor()->program_extensions(); | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | 280 | my %program_extensions = hashify( @{ $extension_list } ); | |||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | 280 | $self->{_program_extensions} = [keys %program_extensions]; | |||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | 280 | return; | |||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 772 | # Begin ACCESSOR methods | ||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||
| 774 | sub _profile { | ||||||||||||||||||||||||||||
| 775 | 26103 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_profile: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 776 | 26103 | return $self->{_profile}; | |||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||
| 779 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||
| 781 | sub all_policies_enabled_or_not { | ||||||||||||||||||||||||||||
| 782 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
all_policies_enabled_or_not: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 783 | 2 | return @{ $self->{_all_policies_enabled_or_not} }; | |||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||
| 786 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||
| 788 | sub policies { | ||||||||||||||||||||||||||||
| 789 | 206 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
policies: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 790 | 206 | return @{ $self->{_policies} }; | |||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||
| 793 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||
| 795 | sub exclude { | ||||||||||||||||||||||||||||
| 796 | 11023 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
exclude: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 797 | 11023 | return @{ $self->{_exclude} }; | |||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||
| 800 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||
| 802 | sub force { | ||||||||||||||||||||||||||||
| 803 | 93 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
force: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 804 | 93 | return $self->{_force}; | |||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||
| 807 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||
| 809 | sub include { | ||||||||||||||||||||||||||||
| 810 | 11023 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
include: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 811 | 11023 | return @{ $self->{_include} }; | |||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | sub only { | ||||||||||||||||||||||||||||
| 817 | 11027 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
only: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 818 | 11027 | return $self->{_only}; | |||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | sub profile_strictness { | ||||||||||||||||||||||||||||
| 824 | 283 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
profile_strictness: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 825 | 283 | return $self->{_profile_strictness}; | |||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||
| 828 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||
| 830 | sub severity { | ||||||||||||||||||||||||||||
| 831 | 12 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 832 | 12 | return $self->{_severity}; | |||||||||||||||||||||||||||
| 833 | } | ||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||
| 835 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | sub single_policy { | ||||||||||||||||||||||||||||
| 838 | 12265 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
single_policy: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 839 | 12265 | return @{ $self->{_single_policy} }; | |||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||
| 842 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||
| 844 | sub theme { | ||||||||||||||||||||||||||||
| 845 | 11026 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
theme: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 846 | 11026 | return $self->{_theme}; | |||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||
| 849 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | sub top { | ||||||||||||||||||||||||||||
| 852 | 71 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
top: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 853 | 71 | return $self->{_top}; | |||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||
| 856 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | sub verbose { | ||||||||||||||||||||||||||||
| 859 | 7 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 860 | 7 | return $self->{_verbose}; | |||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||
| 865 | sub color { | ||||||||||||||||||||||||||||
| 866 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
color: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 867 | 6 | return $self->{_color}; | |||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||
| 870 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||
| 872 | sub pager { | ||||||||||||||||||||||||||||
| 873 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pager: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 874 | 4 | return $self->{_pager}; | |||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||
| 877 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||
| 879 | sub unsafe_allowed { | ||||||||||||||||||||||||||||
| 880 | 7 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
unsafe_allowed: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 881 | 7 | return $self->{_unsafe_allowed}; | |||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||
| 886 | sub criticism_fatal { | ||||||||||||||||||||||||||||
| 887 | 3 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
criticism_fatal: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 888 | 3 | return $self->{_criticism_fatal}; | |||||||||||||||||||||||||||
| 889 | } | ||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||
| 893 | sub site_policy_names { | ||||||||||||||||||||||||||||
| 894 | 0 | ▶ | return Perl::Critic::PolicyFactory::site_policy_names(); | ||||||||||||||||||||||||||
|
Subroutine
site_policy_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||
| 897 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||
| 899 | sub color_severity_highest { | ||||||||||||||||||||||||||||
| 900 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
color_severity_highest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 901 | 6 | return $self->{_color_severity_highest}; | |||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||
| 904 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | sub color_severity_high { | ||||||||||||||||||||||||||||
| 907 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
color_severity_high: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 908 | 6 | return $self->{_color_severity_high}; | |||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||
| 913 | sub color_severity_medium { | ||||||||||||||||||||||||||||
| 914 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
color_severity_medium: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 915 | 6 | return $self->{_color_severity_medium}; | |||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||
| 918 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||
| 920 | sub color_severity_low { | ||||||||||||||||||||||||||||
| 921 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
color_severity_low: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 922 | 6 | return $self->{_color_severity_low}; | |||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||
| 927 | sub color_severity_lowest { | ||||||||||||||||||||||||||||
| 928 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
color_severity_lowest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 929 | 6 | return $self->{_color_severity_lowest}; | |||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||
| 934 | sub program_extensions { | ||||||||||||||||||||||||||||
| 935 | 91 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
program_extensions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 936 | 91 | return @{ $self->{_program_extensions} }; | |||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||
| 939 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||
| 941 | sub program_extensions_as_regexes { | ||||||||||||||||||||||||||||
| 942 | 87 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
program_extensions_as_regexes: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | 0 | return @{ $self->{_program_extensions_as_regexes} } | |||||||||||||||||||||||||||
| 945 | 87 | ▶ | if $self->{_program_extensions_as_regexes}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||
| 947 | 87 | my %program_extensions = hashify( $self->program_extensions() ); | |||||||||||||||||||||||||||
| 948 | 87 | $program_extensions{'.PL'} = 1; | |||||||||||||||||||||||||||
| 949 | return @{ | ||||||||||||||||||||||||||||
| 950 | 87 | $self->{_program_extensions_as_regexes} = [ | |||||||||||||||||||||||||||
| 951 | 87 | map { qr< @{[quotemeta $_]} \z >smx } sort keys %program_extensions | |||||||||||||||||||||||||||
| 952 | ] | ||||||||||||||||||||||||||||
| 953 | }; | ||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||
| 956 | 40 | 1; | |||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||
| 958 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||
| 960 | __END__ | ||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||
| 962 | =pod | ||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||
| 964 | =for stopwords colour INI-style -params | ||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||
| 966 | =head1 NAME | ||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||
| 968 | Perl::Critic::Config - The final derived Perl::Critic configuration, combined from any profile file and command-line parameters. | ||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||
| 971 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||
| 973 | Perl::Critic::Config takes care of finding and processing | ||||||||||||||||||||||||||||
| 974 | user-preferences for L<Perl::Critic|Perl::Critic>. The Config object | ||||||||||||||||||||||||||||
| 975 | defines which Policy modules will be loaded into the Perl::Critic | ||||||||||||||||||||||||||||
| 976 | engine and how they should be configured. You should never really | ||||||||||||||||||||||||||||
| 977 | need to instantiate Perl::Critic::Config directly because the | ||||||||||||||||||||||||||||
| 978 | Perl::Critic constructor will do it for you. | ||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||
| 981 | =head1 INTERFACE SUPPORT | ||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||
| 983 | This is considered to be a non-public class. Its interface is subject | ||||||||||||||||||||||||||||
| 984 | to change without notice. | ||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||
| 987 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||
| 989 | =over | ||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||
| 991 | =item C<< new(...) >> | ||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||
| 993 | Not properly documented because you shouldn't be using this. | ||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||
| 996 | =back | ||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||
| 998 | =head1 METHODS | ||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||
| 1000 | =over | ||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||
| 1002 | =item C<< add_policy( -policy => $policy_name, -params => \%param_hash ) >> | ||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||
| 1004 | Creates a Policy object and loads it into this Config. If the object | ||||||||||||||||||||||||||||
| 1005 | cannot be instantiated, it will throw a fatal exception. Otherwise, | ||||||||||||||||||||||||||||
| 1006 | it returns a reference to this Critic. | ||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||
| 1008 | B<-policy> is the name of a | ||||||||||||||||||||||||||||
| 1009 | L<Perl::Critic::Policy|Perl::Critic::Policy> subclass module. The | ||||||||||||||||||||||||||||
| 1010 | C<'Perl::Critic::Policy'> portion of the name can be omitted for | ||||||||||||||||||||||||||||
| 1011 | brevity. This argument is required. | ||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||
| 1013 | B<-params> is an optional reference to a hash of Policy parameters. | ||||||||||||||||||||||||||||
| 1014 | The contents of this hash reference will be passed into to the | ||||||||||||||||||||||||||||
| 1015 | constructor of the Policy module. See the documentation in the | ||||||||||||||||||||||||||||
| 1016 | relevant Policy module for a description of the arguments it supports. | ||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||
| 1019 | =item C< all_policies_enabled_or_not() > | ||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||
| 1021 | Returns a list containing references to all the Policy objects that | ||||||||||||||||||||||||||||
| 1022 | have been seen. Note that the state of these objects is not | ||||||||||||||||||||||||||||
| 1023 | trustworthy. In particular, it is likely that some of them are not | ||||||||||||||||||||||||||||
| 1024 | prepared to examine any documents. | ||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||
| 1027 | =item C< policies() > | ||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||
| 1029 | Returns a list containing references to all the Policy objects that | ||||||||||||||||||||||||||||
| 1030 | have been enabled and loaded into this Config. | ||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||
| 1033 | =item C< exclude() > | ||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||
| 1035 | Returns the value of the C<-exclude> attribute for this Config. | ||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||
| 1038 | =item C< include() > | ||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||
| 1040 | Returns the value of the C<-include> attribute for this Config. | ||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||
| 1042 | |||||||||||||||||||||||||||||
| 1043 | =item C< force() > | ||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||
| 1045 | Returns the value of the C<-force> attribute for this Config. | ||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||
| 1048 | =item C< only() > | ||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||
| 1050 | Returns the value of the C<-only> attribute for this Config. | ||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||
| 1053 | =item C< profile_strictness() > | ||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||
| 1055 | Returns the value of the C<-profile-strictness> attribute for this | ||||||||||||||||||||||||||||
| 1056 | Config. | ||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||
| 1059 | =item C< severity() > | ||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||
| 1061 | Returns the value of the C<-severity> attribute for this Config. | ||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | =item C< single_policy() > | ||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||
| 1066 | Returns the value of the C<-single-policy> attribute for this Config. | ||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||
| 1069 | =item C< theme() > | ||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||
| 1071 | Returns the L<Perl::Critic::Theme|Perl::Critic::Theme> object that was | ||||||||||||||||||||||||||||
| 1072 | created for this Config. | ||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||
| 1075 | =item C< top() > | ||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||
| 1077 | Returns the value of the C<-top> attribute for this Config. | ||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||
| 1080 | =item C< verbose() > | ||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||
| 1082 | Returns the value of the C<-verbose> attribute for this Config. | ||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||
| 1085 | =item C< color() > | ||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||
| 1087 | Returns the value of the C<-color> attribute for this Config. | ||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||
| 1090 | =item C< pager() > | ||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||
| 1092 | Returns the value of the C<-pager> attribute for this Config. | ||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||
| 1095 | =item C< unsafe_allowed() > | ||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||
| 1097 | Returns the value of the C<-allow-unsafe> attribute for this Config. | ||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||
| 1100 | =item C< criticism_fatal() > | ||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||
| 1102 | Returns the value of the C<-criticism-fatal> attribute for this Config. | ||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||
| 1105 | =item C< color_severity_highest() > | ||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||
| 1107 | Returns the value of the C<-color-severity-highest> attribute for this | ||||||||||||||||||||||||||||
| 1108 | Config. | ||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||
| 1111 | =item C< color_severity_high() > | ||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||
| 1113 | Returns the value of the C<-color-severity-high> attribute for this | ||||||||||||||||||||||||||||
| 1114 | Config. | ||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||
| 1117 | =item C< color_severity_medium() > | ||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||
| 1119 | Returns the value of the C<-color-severity-medium> attribute for this | ||||||||||||||||||||||||||||
| 1120 | Config. | ||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||
| 1123 | =item C< color_severity_low() > | ||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||
| 1125 | Returns the value of the C<-color-severity-low> attribute for this | ||||||||||||||||||||||||||||
| 1126 | Config. | ||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||
| 1129 | =item C< color_severity_lowest() > | ||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||
| 1131 | Returns the value of the C<-color-severity-lowest> attribute for this | ||||||||||||||||||||||||||||
| 1132 | Config. | ||||||||||||||||||||||||||||
| 1133 | |||||||||||||||||||||||||||||
| 1134 | =item C< program_extensions() > | ||||||||||||||||||||||||||||
| 1135 | |||||||||||||||||||||||||||||
| 1136 | Returns the value of the C<-program_extensions> attribute for this Config. | ||||||||||||||||||||||||||||
| 1137 | This is an array of the file name extensions that represent program files. | ||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||
| 1139 | =item C< program_extensions_as_regexes() > | ||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||
| 1141 | Returns the value of the C<-program_extensions> attribute for this Config, as | ||||||||||||||||||||||||||||
| 1142 | an array of case-sensitive regexes matching the ends of the file names that | ||||||||||||||||||||||||||||
| 1143 | represent program files. | ||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||
| 1145 | =back | ||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||
| 1148 | =head1 SUBROUTINES | ||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||
| 1150 | Perl::Critic::Config has a few static subroutines that are used | ||||||||||||||||||||||||||||
| 1151 | internally, but may be useful to you in some way. | ||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||
| 1154 | =over | ||||||||||||||||||||||||||||
| 1155 | |||||||||||||||||||||||||||||
| 1156 | =item C<site_policy_names()> | ||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||
| 1158 | Returns a list of all the Policy modules that are currently installed | ||||||||||||||||||||||||||||
| 1159 | in the Perl::Critic:Policy namespace. These will include modules that | ||||||||||||||||||||||||||||
| 1160 | are distributed with Perl::Critic plus any third-party modules that | ||||||||||||||||||||||||||||
| 1161 | have been installed. | ||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||
| 1164 | =back | ||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||
| 1167 | =head1 CONFIGURATION | ||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||
| 1169 | Most of the settings for Perl::Critic and each of the Policy modules | ||||||||||||||||||||||||||||
| 1170 | can be controlled by a configuration file. The default configuration | ||||||||||||||||||||||||||||
| 1171 | file is called F<.perlcriticrc>. | ||||||||||||||||||||||||||||
| 1172 | L<Perl::Critic::Config|Perl::Critic::Config> will look for this file | ||||||||||||||||||||||||||||
| 1173 | in the current directory first, and then in your home directory. | ||||||||||||||||||||||||||||
| 1174 | Alternatively, you can set the C<PERLCRITIC> environment variable to | ||||||||||||||||||||||||||||
| 1175 | explicitly point to a different file in another location. If none of | ||||||||||||||||||||||||||||
| 1176 | these files exist, and the C<-profile> option is not given to the | ||||||||||||||||||||||||||||
| 1177 | constructor, then all Policies will be loaded with their default | ||||||||||||||||||||||||||||
| 1178 | configuration. | ||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||
| 1180 | The format of the configuration file is a series of INI-style blocks | ||||||||||||||||||||||||||||
| 1181 | that contain key-value pairs separated by '='. Comments should start | ||||||||||||||||||||||||||||
| 1182 | with '#' and can be placed on a separate line or after the name-value | ||||||||||||||||||||||||||||
| 1183 | pairs if you desire. | ||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||
| 1185 | Default settings for Perl::Critic itself can be set B<before the first | ||||||||||||||||||||||||||||
| 1186 | named block.> For example, putting any or all of these at the top of | ||||||||||||||||||||||||||||
| 1187 | your configuration file will set the default value for the | ||||||||||||||||||||||||||||
| 1188 | corresponding Perl::Critic constructor argument. | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | severity = 3 #Integer from 1 to 5 | ||||||||||||||||||||||||||||
| 1191 | only = 1 #Zero or One | ||||||||||||||||||||||||||||
| 1192 | force = 0 #Zero or One | ||||||||||||||||||||||||||||
| 1193 | verbose = 4 #Integer or format spec | ||||||||||||||||||||||||||||
| 1194 | top = 50 #A positive integer | ||||||||||||||||||||||||||||
| 1195 | theme = risky + (pbp * security) - cosmetic #A theme expression | ||||||||||||||||||||||||||||
| 1196 | include = NamingConventions ClassHierarchies #Space-delimited list | ||||||||||||||||||||||||||||
| 1197 | exclude = Variables Modules::RequirePackage #Space-delimited list | ||||||||||||||||||||||||||||
| 1198 | color = 1 #Zero or One | ||||||||||||||||||||||||||||
| 1199 | allow_unsafe = 1 #Zero or One | ||||||||||||||||||||||||||||
| 1200 | color-severity-highest = bold red #Term::ANSIColor | ||||||||||||||||||||||||||||
| 1201 | color-severity-high = magenta #Term::ANSIColor | ||||||||||||||||||||||||||||
| 1202 | color-severity-medium = #no coloring | ||||||||||||||||||||||||||||
| 1203 | color-severity-low = #no coloring | ||||||||||||||||||||||||||||
| 1204 | color-severity-lowest = #no coloring | ||||||||||||||||||||||||||||
| 1205 | program-extensions = #Space-delimited list | ||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||
| 1207 | The remainder of the configuration file is a series of blocks like | ||||||||||||||||||||||||||||
| 1208 | this: | ||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||
| 1210 | [Perl::Critic::Policy::Category::PolicyName] | ||||||||||||||||||||||||||||
| 1211 | severity = 1 | ||||||||||||||||||||||||||||
| 1212 | set_themes = foo bar | ||||||||||||||||||||||||||||
| 1213 | add_themes = baz | ||||||||||||||||||||||||||||
| 1214 | arg1 = value1 | ||||||||||||||||||||||||||||
| 1215 | arg2 = value2 | ||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||
| 1217 | C<Perl::Critic::Policy::Category::PolicyName> is the full name of a | ||||||||||||||||||||||||||||
| 1218 | module that implements the policy. The Policy modules distributed | ||||||||||||||||||||||||||||
| 1219 | with Perl::Critic have been grouped into categories according to the | ||||||||||||||||||||||||||||
| 1220 | table of contents in Damian Conway's book B<Perl Best Practices>. For | ||||||||||||||||||||||||||||
| 1221 | brevity, you can omit the C<'Perl::Critic::Policy'> part of the module | ||||||||||||||||||||||||||||
| 1222 | name. | ||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||
| 1224 | C<severity> is the level of importance you wish to assign to the | ||||||||||||||||||||||||||||
| 1225 | Policy. All Policy modules are defined with a default severity value | ||||||||||||||||||||||||||||
| 1226 | ranging from 1 (least severe) to 5 (most severe). However, you may | ||||||||||||||||||||||||||||
| 1227 | disagree with the default severity and choose to give it a higher or | ||||||||||||||||||||||||||||
| 1228 | lower severity, based on your own coding philosophy. | ||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||
| 1230 | The remaining key-value pairs are configuration parameters that will | ||||||||||||||||||||||||||||
| 1231 | be passed into the constructor of that Policy. The constructors for | ||||||||||||||||||||||||||||
| 1232 | most Policy modules do not support arguments, and those that do should | ||||||||||||||||||||||||||||
| 1233 | have reasonable defaults. See the documentation on the appropriate | ||||||||||||||||||||||||||||
| 1234 | Policy module for more details. | ||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||
| 1236 | Instead of redefining the severity for a given Policy, you can | ||||||||||||||||||||||||||||
| 1237 | completely disable a Policy by prepending a '-' to the name of the | ||||||||||||||||||||||||||||
| 1238 | module in your configuration file. In this manner, the Policy will | ||||||||||||||||||||||||||||
| 1239 | never be loaded, regardless of the C<-severity> given to the | ||||||||||||||||||||||||||||
| 1240 | Perl::Critic::Config constructor. | ||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||
| 1242 | A simple configuration might look like this: | ||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||
| 1244 | #-------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1245 | # I think these are really important, so always load them | ||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||
| 1247 | [TestingAndDebugging::RequireUseStrict] | ||||||||||||||||||||||||||||
| 1248 | severity = 5 | ||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||
| 1250 | [TestingAndDebugging::RequireUseWarnings] | ||||||||||||||||||||||||||||
| 1251 | severity = 5 | ||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||
| 1253 | #-------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1254 | # I think these are less important, so only load when asked | ||||||||||||||||||||||||||||
| 1255 | |||||||||||||||||||||||||||||
| 1256 | [Variables::ProhibitPackageVars] | ||||||||||||||||||||||||||||
| 1257 | severity = 2 | ||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||
| 1259 | [ControlStructures::ProhibitPostfixControls] | ||||||||||||||||||||||||||||
| 1260 | allow = if unless #My custom configuration | ||||||||||||||||||||||||||||
| 1261 | severity = 2 | ||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||
| 1263 | #-------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1264 | # Give these policies a custom theme. I can activate just | ||||||||||||||||||||||||||||
| 1265 | # these policies by saying (-theme => 'larry + curly') | ||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||
| 1267 | [Modules::RequireFilenameMatchesPackage] | ||||||||||||||||||||||||||||
| 1268 | add_themes = larry | ||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||
| 1270 | [TestingAndDebugging::RequireTestLabels] | ||||||||||||||||||||||||||||
| 1271 | add_themes = curly moe | ||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||
| 1273 | #-------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1274 | # I do not agree with these at all, so never load them | ||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||
| 1276 | [-NamingConventions::Capitalization] | ||||||||||||||||||||||||||||
| 1277 | [-ValuesAndExpressions::ProhibitMagicNumbers] | ||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||
| 1279 | #-------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1280 | # For all other Policies, I accept the default severity, theme | ||||||||||||||||||||||||||||
| 1281 | # and other parameters, so no additional configuration is | ||||||||||||||||||||||||||||
| 1282 | # required for them. | ||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||
| 1284 | For additional configuration examples, see the F<perlcriticrc> file | ||||||||||||||||||||||||||||
| 1285 | that is included in this F<t/examples> directory of this distribution. | ||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||
| 1288 | =head1 THE POLICIES | ||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||
| 1290 | A large number of Policy modules are distributed with Perl::Critic. | ||||||||||||||||||||||||||||
| 1291 | They are described briefly in the companion document | ||||||||||||||||||||||||||||
| 1292 | L<Perl::Critic::PolicySummary|Perl::Critic::PolicySummary> and in more | ||||||||||||||||||||||||||||
| 1293 | detail in the individual modules themselves. | ||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||
| 1296 | =head1 POLICY THEMES | ||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||
| 1298 | Each Policy is defined with one or more "themes". Themes can be used | ||||||||||||||||||||||||||||
| 1299 | to create arbitrary groups of Policies. They are intended to provide | ||||||||||||||||||||||||||||
| 1300 | an alternative mechanism for selecting your preferred set of Policies. | ||||||||||||||||||||||||||||
| 1301 | For example, you may wish disable a certain subset of Policies when | ||||||||||||||||||||||||||||
| 1302 | analyzing test programs. Conversely, you may wish to enable only a | ||||||||||||||||||||||||||||
| 1303 | specific subset of Policies when analyzing modules. | ||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||
| 1305 | The Policies that ship with Perl::Critic are have been broken into the | ||||||||||||||||||||||||||||
| 1306 | following themes. This is just our attempt to provide some basic | ||||||||||||||||||||||||||||
| 1307 | logical groupings. You are free to invent new themes that suit your | ||||||||||||||||||||||||||||
| 1308 | needs. | ||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||
| 1310 | THEME DESCRIPTION | ||||||||||||||||||||||||||||
| 1311 | -------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1312 | core All policies that ship with Perl::Critic | ||||||||||||||||||||||||||||
| 1313 | pbp Policies that come directly from "Perl Best Practices" | ||||||||||||||||||||||||||||
| 1314 | bugs Policies that prevent or reveal bugs | ||||||||||||||||||||||||||||
| 1315 | maintenance Policies that affect the long-term health of the code | ||||||||||||||||||||||||||||
| 1316 | cosmetic Policies that only have a superficial effect | ||||||||||||||||||||||||||||
| 1317 | complexity Policies that specifically relate to code complexity | ||||||||||||||||||||||||||||
| 1318 | security Policies that relate to security issues | ||||||||||||||||||||||||||||
| 1319 | tests Policies that are specific to test programs | ||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||
| 1321 | Say C<`perlcritic -list`> to get a listing of all available policies | ||||||||||||||||||||||||||||
| 1322 | and the themes that are associated with each one. You can also change | ||||||||||||||||||||||||||||
| 1323 | the theme for any Policy in your F<.perlcriticrc> file. See the | ||||||||||||||||||||||||||||
| 1324 | L<"CONFIGURATION"> section for more information about that. | ||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||
| 1326 | Using the C<-theme> option, you can combine theme names with | ||||||||||||||||||||||||||||
| 1327 | mathematical and boolean operators to create an arbitrarily complex | ||||||||||||||||||||||||||||
| 1328 | expression that represents a custom "set" of Policies. The following | ||||||||||||||||||||||||||||
| 1329 | operators are supported | ||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||
| 1331 | Operator Alternative Meaning | ||||||||||||||||||||||||||||
| 1332 | ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1333 | * and Intersection | ||||||||||||||||||||||||||||
| 1334 | - not Difference | ||||||||||||||||||||||||||||
| 1335 | + or Union | ||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||
| 1337 | Operator precedence is the same as that of normal mathematics. You | ||||||||||||||||||||||||||||
| 1338 | can also use parenthesis to enforce precedence. Here are some | ||||||||||||||||||||||||||||
| 1339 | examples: | ||||||||||||||||||||||||||||
| 1340 | |||||||||||||||||||||||||||||
| 1341 | Expression Meaning | ||||||||||||||||||||||||||||
| 1342 | ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1343 | pbp * bugs All policies that are "pbp" AND "bugs" | ||||||||||||||||||||||||||||
| 1344 | pbp and bugs Ditto | ||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||
| 1346 | bugs + cosmetic All policies that are "bugs" OR "cosmetic" | ||||||||||||||||||||||||||||
| 1347 | bugs or cosmetic Ditto | ||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||
| 1349 | pbp - cosmetic All policies that are "pbp" BUT NOT "cosmetic" | ||||||||||||||||||||||||||||
| 1350 | pbp not cosmetic Ditto | ||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||
| 1352 | -maintenance All policies that are NOT "maintenance" | ||||||||||||||||||||||||||||
| 1353 | not maintenance Ditto | ||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||
| 1355 | (pbp - bugs) * complexity All policies that are "pbp" BUT NOT "bugs", | ||||||||||||||||||||||||||||
| 1356 | AND "complexity" | ||||||||||||||||||||||||||||
| 1357 | (pbp not bugs) and complexity Ditto | ||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||
| 1359 | Theme names are case-insensitive. If C<-theme> is set to an empty | ||||||||||||||||||||||||||||
| 1360 | string, then it is equivalent to the set of all Policies. A theme | ||||||||||||||||||||||||||||
| 1361 | name that doesn't exist is equivalent to an empty set. Please See | ||||||||||||||||||||||||||||
| 1362 | L<http://en.wikipedia.org/wiki/Set> for a discussion on set theory. | ||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||
| 1365 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||
| 1367 | L<Perl::Critic::OptionsProcessor|Perl::Critic::OptionsProcessor>, | ||||||||||||||||||||||||||||
| 1368 | L<Perl::Critic::UserProfile|Perl::Critic::UserProfile> | ||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||
| 1371 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||
| 1373 | Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> | ||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||
| 1375 | |||||||||||||||||||||||||||||
| 1376 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||
| 1378 | Copyright (c) 2005-2023 Imaginative Software Systems | ||||||||||||||||||||||||||||
| 1379 | |||||||||||||||||||||||||||||
| 1380 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 1381 | it under the same terms as Perl itself. The full text of this license | ||||||||||||||||||||||||||||
| 1382 | can be found in the LICENSE file included with this module. | ||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||
| 1384 | =cut | ||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||
| 1386 | ############################################################################## | ||||||||||||||||||||||||||||
| 1387 | # Local Variables: | ||||||||||||||||||||||||||||
| 1388 | # mode: cperl | ||||||||||||||||||||||||||||
| 1389 | # cperl-indent-level: 4 | ||||||||||||||||||||||||||||
| 1390 | # fill-column: 78 | ||||||||||||||||||||||||||||
| 1391 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||
| 1392 | # c-indentation-style: bsd | ||||||||||||||||||||||||||||
| 1393 | # End: | ||||||||||||||||||||||||||||
| 1394 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : | ||||||||||||||||||||||||||||