lib/Perl/Critic/PolicyConfig.pm

filter: Statementstmt 100% 83 / 83 Branchbran 81.2% 13 / 16 Conditioncond 75.0% 9 / 12 MC/DCmcdc 28.5% 2 / 7 Subroutinesub 100% 23 / 23 Podpod 92.3% 12 / 13 totaltotal 92.2% 142 / 154 CC 15 SCAR 10.9
CC
15
Cov
95%
handle_extra_parameters
7.4
is_maximum_violations_per_document_unlimited
4.0
new
4.0
CRAP 3.0
« lib/Perl/Critic/Policy/Subroutines/ProhibitReturnSort.pm ↑ Summary lib/Perl/Critic/Policy/Subroutines/ProhibitExplicitReturnUndef.pm »
1 package Perl::Critic::PolicyConfig;
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 Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 40 our $VERSION = '1.156';
10  
11 40 ▶use Perl::Critic::Exception::AggregateConfiguration;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 40 ▶use Perl::Critic::Exception::Configuration::Option::Policy::ParameterValue;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 40 ▶use Perl::Critic::Exception::Configuration::Option::Policy::ExtraParameter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 40 ▶use Perl::Critic::Utils qw( :booleans :characters );
Subroutine BEGIN: called CC=1 SCAR=0.0
15 40 ▶use Perl::Critic::Utils::Constants qw< :profile_strictness >;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 #-----------------------------------------------------------------------------
18  
19 40 Readonly::Scalar my $NON_PUBLIC_DATA => '_non_public_data';
20 40 Readonly::Scalar my $NO_LIMIT => 'no_limit';
21  
22 #-----------------------------------------------------------------------------
23  
24 25756 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod undocumented
25 25756 my ($class, $policy_short_name, $specification) = @_;
26  
27 25756 ▶ my %self = $specification ? %{ $specification } : ();
Branch: 1 branch
BranchTrueFalseTotal
$specification ? : 25755 1 25756
28 25756 my %non_public_data;
29  
30 25756 $non_public_data{_policy_short_name} = $policy_short_name;
31 $non_public_data{_profile_strictness} =
32 25756 $self{$NON_PUBLIC_DATA}{_profile_strictness};
33  
34 25756 foreach my $standard_parameter (
35 qw< maximum_violations_per_document severity set_themes add_themes >
36 ) {
37 103024 ▶ if ( exists $self{$standard_parameter} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self{$standard_parameter}) 1305 101719 103024
38 $non_public_data{"_$standard_parameter"} =
39 1305 delete $self{$standard_parameter};
40 }
41 }
42  
43 25756 $self{$NON_PUBLIC_DATA} = \%non_public_data;
44  
45  
46 25756 return bless \%self, $class;
47 }
48  
49 #-----------------------------------------------------------------------------
50  
51 50522 ▶sub _get_non_public_data {
Subroutine _get_non_public_data: called CC=1 SCAR=0.0
52 50522 my $self = shift;
53  
54 50522 return $self->{$NON_PUBLIC_DATA};
55 }
56  
57 #-----------------------------------------------------------------------------
58  
59 4 ▶sub get_policy_short_name {
Subroutine get_policy_short_name: called CC=1 SCAR=0.0
Pod documented
60 4 my $self = shift;
61  
62 4 return $self->_get_non_public_data()->{_policy_short_name};
63 }
64  
65 #-----------------------------------------------------------------------------
66  
67 12628 ▶sub get_set_themes {
Subroutine get_set_themes: called CC=1 SCAR=0.0
Pod documented
68 12628 my ($self) = @_;
69  
70 12628 return $self->_get_non_public_data()->{_set_themes};
71 }
72  
73 #-----------------------------------------------------------------------------
74  
75 12628 ▶sub get_add_themes {
Subroutine get_add_themes: called CC=1 SCAR=0.0
Pod documented
76 12628 my ($self) = @_;
77  
78 12628 return $self->_get_non_public_data()->{_add_themes};
79 }
80  
81 #-----------------------------------------------------------------------------
82  
83 12629 ▶sub get_severity {
Subroutine get_severity: called CC=1 SCAR=0.0
Pod documented
84 12629 my ($self) = @_;
85  
86 12629 return $self->_get_non_public_data()->{_severity};
87 }
88  
89 #-----------------------------------------------------------------------------
90  
91 12627 ▶sub is_maximum_violations_per_document_unlimited {
Subroutine is_maximum_violations_per_document_unlimited: called CC=4 SCAR=13.9
Pod documented
92 12627 my ($self) = @_;
93  
94 12627 my $maximum_violations = $self->get_maximum_violations_per_document();
95 12627 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $maximum_violations or $maximum_violations eq $Perl::Critic::PolicyConfig::EMPTY or $maximum_violations =~ /\A $NO_LIMIT \z/imosx) 12623 4 12627
Condition83%5/6
not defined $maximum_violations or $maximum_violations eq $Perl::Critic::PolicyConfig::EMPTY or $maximum_violations =~ /\A $NO_LIMIT \z/imosx
l!l&&r!l&&!r
124841394
not defined $maximum_violations or $maximum_violations eq $Perl::Critic::PolicyConfig::EMPTY
l!l&&r!l&&!r
124840143
MC/DC66%2/3
not defined $maximum_violations or $maximum_violations eq $Perl::Critic::PolicyConfig::EMPTY or $maximum_violations =~ /\A $NO_LIMIT \z/imosx
not defined $maximum_violations $maximum_violations eq $Perl::Critic::PolicyConfig::EMPTY $maximum_violations =~ /\A $NO_LIMIT \z/imosx
Truth table75%3/4
not(A) or B or C
A= not defined $maximum_violationsB= $maximum_violations eq $Perl::Critic::PolicyConfig::EMPTYC= $maximum_violations =~ /\A $NO_LIMIT \z/imosx
ABCresult
1XX1
01X1
0011
0000
96 not defined $maximum_violations
97 or $maximum_violations eq $EMPTY
98 or $maximum_violations =~ m<\A $NO_LIMIT \z>xmsio
99 ) {
100 12623 return $TRUE;
101 }
102  
103 4 return $FALSE;
104 }
105  
106 #-----------------------------------------------------------------------------
107  
108 12633 ▶sub get_maximum_violations_per_document {
Subroutine get_maximum_violations_per_document: called CC=1 SCAR=0.0
Pod documented
109 12633 my ($self) = @_;
110  
111 12633 return $self->_get_non_public_data()->{_maximum_violations_per_document};
112 }
113  
114 #-----------------------------------------------------------------------------
115  
116 11 ▶sub get {
Subroutine get: called CC=2 SCAR=6.9
Pod documented
117 11 my ($self, $parameter) = @_;
118  
119 11 ▶ return if $parameter eq $NON_PUBLIC_DATA;
Branch: 1 branch
BranchTrueFalseTotal
if $parameter eq $NON_PUBLIC_DATA 2 9 11
120  
121 9 return $self->{$parameter};
122 }
123  
124 #-----------------------------------------------------------------------------
125  
126 9710 ▶sub remove {
Subroutine remove: called CC=2 SCAR=7.0
Pod documented
127 9710 my ($self, $parameter) = @_;
128  
129 9710 ▶ return if $parameter eq $NON_PUBLIC_DATA;
Branch: 1 branch
BranchTrueFalseTotal
if $parameter eq $NON_PUBLIC_DATA 0 9710 9710
130  
131 9710 delete $self->{$parameter};
132  
133 9710 return;
134 }
135  
136 #-----------------------------------------------------------------------------
137  
138 3 ▶sub is_empty {
Subroutine is_empty: called CC=1 SCAR=0.0
Pod documented
139 3 my ($self) = @_;
140  
141 3 return 1 >= keys %{$self};
142 }
143  
144 #-----------------------------------------------------------------------------
145  
146 12922 ▶sub get_parameter_names {
Subroutine get_parameter_names: called CC=1 SCAR=0.0
Pod documented
147 12922 my ($self) = @_;
148  
149 12922 return grep { $_ ne $NON_PUBLIC_DATA } keys %{$self};
150 }
151  
152 #-----------------------------------------------------------------------------
153  
154 12919 ▶sub handle_extra_parameters {
Subroutine handle_extra_parameters: called CC=7 SCAR=20.0
Pod documented
155 12919 my ($self, $policy, $errors) = @_;
156  
157 my $profile_strictness = $self->{$NON_PUBLIC_DATA}{_profile_strictness}
158 12919 ▶ // $PROFILE_STRICTNESS_DEFAULT;
Condition66%2/3
$self->{$NON_PUBLIC_DATA}{"_profile_strictness"} // $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_DEFAULT
l!l&&r!l&&!r
127731460
MC/DC0%0/2
$self->{$NON_PUBLIC_DATA}{"_profile_strictness"} // $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_DEFAULT
$self->{$NON_PUBLIC_DATA}{"_profile_strictness"} $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_DEFAULT
Truth table66%2/3
A // B
A= $self->{$NON_PUBLIC_DATA}{"_profile_strictness"}B= $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_DEFAULT
ABresult
1X1
011
000
159  
160 12919 ▶ return if $profile_strictness eq $PROFILE_STRICTNESS_QUIET;
Branch: 1 branch
BranchTrueFalseTotal
if $profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_QUIET 0 12919 12919
161  
162 12919 ▶ my $parameter_errors = $profile_strictness eq $PROFILE_STRICTNESS_WARN ?
Branch: 1 branch
BranchTrueFalseTotal
$profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_WARN ? : 12629 290 12919
163 Perl::Critic::Exception::AggregateConfiguration->new() : $errors;
164  
165 12919 foreach my $offered_param ( $self->get_parameter_names() ) {
166 145 $parameter_errors->add_exception(
167 Perl::Critic::Exception::Configuration::Option::Policy::ExtraParameter->new(
168 policy => $policy->get_short_name(),
169 option_name => $offered_param,
170 source => undef,
171 )
172 );
173 }
174  
175 12919 ▶ warn qq<$parameter_errors\n>
Branch: 1 branch
BranchTrueFalseTotal
if $profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_WARN and $parameter_errors->has_exceptions 0 12919 12919
Condition66%2/3
$profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_WARN and $parameter_errors->has_exceptions
!ll&&!rl&&r
290126290
MC/DC0%0/2
$profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_WARN and $parameter_errors->has_exceptions
$profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_WARN $parameter_errors->has_exceptions
Truth table66%2/3
A and B
A= $profile_strictness eq $Perl::Critic::PolicyConfig::PROFILE_STRICTNESS_WARNB= $parameter_errors->has_exceptions
ABresult
0X0
100
111
176 if ($profile_strictness eq $PROFILE_STRICTNESS_WARN
177 && $parameter_errors->has_exceptions());
178  
179 12919 return;
180 }
181  
182 #-----------------------------------------------------------------------------
183  
184 12775 ▶sub set_profile_strictness {
Subroutine set_profile_strictness: called CC=1 SCAR=0.0
Pod documented
185 12775 my ($self, $profile_strictness) = @_;
186  
187 12775 $self->{$NON_PUBLIC_DATA}{_profile_strictness} = $profile_strictness;
188  
189 12775 return;
190 }
191  
192 #-----------------------------------------------------------------------------
193  
194 40 1;
195  
196 __END__
« lib/Perl/Critic/Policy/Subroutines/ProhibitReturnSort.pm ↑ Summary lib/Perl/Critic/Policy/Subroutines/ProhibitExplicitReturnUndef.pm »