lib/Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm

filter: Statementstmt 37.2% 51 / 137 Branchbran 10.2% 9 / 88 Conditioncond 4.8% 2 / 41 MC/DCmcdc 0.0% 0 / 23 Subroutinesub 60.8% 14 / 23 Podpod 80.0% 4 / 5 totaltotal 25.2% 80 / 317 CC 68 SCAR 44.8
CC
68
Cov
23%
_find_sub_reference_in_document
182.0
_find_sub_call_in_document
156.0
_find_sub_usage_in_regexp
132.0
CRAP 87.8
« lib/Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm ↑ Summary lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm »
1 package Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines;
2  
3 40 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use English qw< $EVAL_ERROR -no_match_vars >;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use List::SomeUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 40 ▶use Perl::Critic::Utils qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
13 :characters hashify is_function_call is_method_call :severities
14 $EMPTY $TRUE
15 40 };
16 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 40 our $VERSION = '1.156';
19  
20 #-----------------------------------------------------------------------------
21  
22 40 Readonly::Scalar my $DESC =>
23 q{Private subroutine/method '%s' declared but not used};
24 40 Readonly::Scalar my $EXPL => q{Eliminate dead code};
25  
26 40 Readonly::Hash my %IS_COMMA => hashify( $COMMA, $FATCOMMA );
27  
28 #-----------------------------------------------------------------------------
29  
30 94 ▶sub supported_parameters {
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
31 return (
32 {
33 94 name => 'private_name_regex',
34 description => 'Pattern that determines what a private subroutine is.',
35 default_string => '\b_\w+\b', ## no critic (RequireInterpolationOfMetachars)
36 behavior => 'string',
37 parser => \&_parse_regex_parameter,
38 },
39 {
40 name => 'allow',
41 description =>
42 q<Subroutines matching the private name regex to allow under this policy.>,
43 default_string => $EMPTY,
44 behavior => 'string list',
45 },
46 {
47 name => 'skip_when_using',
48 description =>
49 q<Modules that, if used within a file, will cause the policy to be disabled for this file>,
50 default_string => $EMPTY,
51 behavior => 'string list',
52 },
53 {
54 name => 'allow_name_regex',
55 description =>
56 q<Pattern defining private subroutine names that are always allowed>,
57 default_string => $EMPTY,
58 behavior => 'string',
59 parser => \&_parse_regex_parameter,
60 },
61 );
62 }
63  
64 74 ▶sub default_severity { return $SEVERITY_MEDIUM }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
65 73 ▶sub default_themes { return qw( core maintenance certrec ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
66 31 ▶sub applies_to { return 'PPI::Statement::Sub' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
67  
68 #-----------------------------------------------------------------------------
69  
70 184 ▶sub _parse_regex_parameter {
Subroutine _parse_regex_parameter: called CC=3 SCAR=11.1
71 184 my ($self, $parameter, $config_string) = @_;
72  
73 184 ▶ $config_string //= $parameter->get_default_string();
Condition66%2/3
$config_string //= $parameter->get_default_string
l!l&&r!l&&!r
41800
MC/DC0%0/2
$config_string //= $parameter->get_default_string
$config_string $parameter->get_default_string
Truth table66%2/3
A //= B
A= $config_stringB= $parameter->get_default_string
ABresult
1X1
011
000
74  
75 184 my $regex;
76 184 ▶ eval { $regex = qr/$config_string/; 1 } ## no critic (RegularExpressions)
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $regex = qr/$config_string/; 1 } } or $self->throw_parameter_value_exception($parameter, $config_string, undef, "is not a valid regular expression: $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::EVAL_ERROR") 184 0 184
77 or $self->throw_parameter_value_exception(
78 $parameter,
79 $config_string,
80 undef,
81 "is not a valid regular expression: $EVAL_ERROR",
82 );
83  
84 184 $self->__set_parameter_value($parameter, $regex);
85  
86 184 return;
87 }
88  
89 #-----------------------------------------------------------------------------
90  
91 5 ▶sub violates {
Subroutine violates: called CC=12 SCAR=34.0
Pod documented
92 5 my ( $self, $elem, $document ) = @_;
93  
94 5 my @skip_modules = keys %{ $self->{_skip_when_using} };
95 0 ▶ return if any { $document->uses_module($_) } @skip_modules;
Subroutine __ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { $document->uses_module($_); } , @skip_modules) 0 5 5
96  
97 # Not interested in forward declarations, only the real thing.
98 5 ▶ $elem->forward() and return;
Branch: 1 branch
BranchTrueFalseTotal
$elem->forward and return 0 5 5
99  
100 # Not interested in subs without names.
101 5 ▶ my $name = $elem->name() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $name = $elem->name or return 5 0 5
102  
103 # If the sub is shoved into someone else's name space, we wimp out.
104 5 ▶ $name =~ m/ :: /smx and return;
Branch: 1 branch
BranchTrueFalseTotal
$name =~ / :: /msx and return 0 5 5
105  
106 # If the name is explicitly allowed, we just return (OK).
107 5 ▶ $self->{_allow}{$name} and return;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"_allow"}{$name} and return 0 5 5
108  
109 # Allow names that match the 'allow_name_regex' pattern.
110 5 ▶ if ($self->{_allow_name_regex}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_allow_name_regex"}) 5 0 5
111 5 ▶ $name =~ m/ \A $self->{_allow_name_regex} \z /smx and return;
Branch: 1 branch
BranchTrueFalseTotal
$name =~ / \A $self->{"_allow_name_regex"} \z /msx and return 0 5 5
112 }
113  
114 # If the name is not an anonymous subroutine according to our definition,
115 # we just return (OK).
116 5 ▶ $name =~ m/ \A $self->{_private_name_regex} \z /smx or return;
Branch: 1 branch
BranchTrueFalseTotal
$name =~ / \A $self->{"_private_name_regex"} \z /msx or return 0 5 5
117  
118 # If the subroutine is called in the document, just return (OK).
119 0 ▶ return if _find_sub_call_in_document( $elem, $document );
Branch: 1 branch
BranchTrueFalseTotal
if _find_sub_call_in_document($elem, $document) 0 0 0
120  
121 # If the subroutine is referred to in the document, just return (OK).
122 0 ▶ return if _find_sub_reference_in_document( $elem, $document );
Branch: 1 branch
BranchTrueFalseTotal
if _find_sub_reference_in_document($elem, $document) 0 0 0
123  
124 # If the subroutine is used in an overload, just return (OK).
125 0 ▶ return if _find_sub_overload_in_document( $elem, $document );
Branch: 1 branch
BranchTrueFalseTotal
if _find_sub_overload_in_document($elem, $document) 0 0 0
126  
127 # No uses of subroutine found. Return a violation.
128 0 return $self->violation( sprintf( $DESC, $name ), $EXPL, $elem );
129 }
130  
131  
132 # Basically the spaceship operator for token locations. The arguments are the
133 # two tokens to compare. If either location is unavailable we return undef.
134 0 ▶sub _compare_token_locations {
Subroutine _compare_token_locations: not called CC=4 SCAR=30.0
135 0 my ( $left_token, $right_token ) = @_;
136 0 ▶ my $left_loc = $left_token->location() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $left_loc = $left_token->location or return 0 0 0
137 0 ▶ my $right_loc = $right_token->location() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $right_loc = $right_token->location or return 0 0 0
138 0 ▶ return $left_loc->[0] <=> $right_loc->[0] ||
Condition0%0/3
$left_loc->[0] <=> $right_loc->[0] || $left_loc->[1] <=> $right_loc->[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$left_loc->[0] <=> $right_loc->[0] || $left_loc->[1] <=> $right_loc->[1]
$left_loc->[0] <=> $right_loc->[0] $left_loc->[1] <=> $right_loc->[1]
Truth table0%0/3
A || B
A= $left_loc->[0] <=> $right_loc->[0]B= $left_loc->[1] <=> $right_loc->[1]
ABresult
1X1
011
000
139 $left_loc->[1] <=> $right_loc->[1];
140 }
141  
142 # Find out if the subroutine defined in $elem is called in $document. Calls
143 # inside the subroutine itself do not count.
144 0 ▶sub _find_sub_call_in_document {
Subroutine _find_sub_call_in_document: not called CC=12 SCAR=50.5
145 0 my ( $elem, $document ) = @_;
146  
147 0 my $start_token = $elem->first_token();
148 0 my $finish_token = $elem->last_token();
149 0 my $name = $elem->name();
150  
151 0 ▶ if ( my $found = $document->find( 'PPI::Token::Word' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $found = $document->find("PPI::Token::Word")) 0 0 0
152 0 foreach my $usage ( @{ $found } ) {
153 0 ▶ $name eq $usage->content() or next;
Branch: 1 branch
BranchTrueFalseTotal
$name eq $usage->content or next 0 0 0
154 0 ▶ is_function_call( $usage )
Branch: 1 branch
BranchTrueFalseTotal
is_function_call($usage) or is_method_call($usage) or next 0 0 0
Condition0%0/3
is_function_call($usage) or is_method_call($usage)
l!l&&r!l&&!r
000
MC/DC0%0/2
is_function_call($usage) or is_method_call($usage)
is_function_call($usage) is_method_call($usage)
Truth table0%0/3
A or B
A= is_function_call($usage)B= is_method_call($usage)
ABresult
1X1
011
000
155 or is_method_call( $usage )
156 or next;
157 0 ▶ _compare_token_locations( $usage, $start_token ) < 0
Branch: 1 branch
BranchTrueFalseTotal
_compare_token_locations($usage, $start_token) < 0 and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
158 and return $TRUE;
159 0 ▶ _compare_token_locations( $finish_token, $usage ) < 0
Branch: 1 branch
BranchTrueFalseTotal
_compare_token_locations($finish_token, $usage) < 0 and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
160 and return $TRUE;
161 }
162 }
163  
164 0 foreach my $regexp ( _find_regular_expressions( $document ) ) {
165  
166 0 ▶ _compare_token_locations( $regexp, $start_token ) >= 0
Branch: 1 branch
BranchTrueFalseTotal
_compare_token_locations($regexp, $start_token) >= 0 and _compare_token_locations($finish_token, $regexp) >= 0 and next 0 0 0
Condition0%0/3
_compare_token_locations($regexp, $start_token) >= 0 and _compare_token_locations($finish_token, $regexp) >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
_compare_token_locations($regexp, $start_token) >= 0 and _compare_token_locations($finish_token, $regexp) >= 0
_compare_token_locations($regexp, $start_token) >= 0 _compare_token_locations($finish_token, $regexp) >= 0
Truth table0%0/3
A and B
A= _compare_token_locations($regexp, $start_token) >= 0B= _compare_token_locations($finish_token, $regexp) >= 0
ABresult
0X0
100
111
167 and _compare_token_locations( $finish_token, $regexp ) >= 0
168 and next;
169 0 ▶ _find_sub_usage_in_regexp( $name, $regexp, $document )
Branch: 1 branch
BranchTrueFalseTotal
_find_sub_usage_in_regexp($name, $regexp, $document) and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
170 and return $TRUE;
171  
172 }
173  
174 0 return;
175 }
176  
177 # Find analyzable regular expressions in the given document. This means
178 # matches, substitutions, and the qr{} operator.
179 0 ▶sub _find_regular_expressions {
Subroutine _find_regular_expressions: not called CC=2 SCAR=17.9
180 0 my ( $document ) = @_;
181  
182 0 ▶ return ( map { @{ $document->find( $_ ) || [] } } qw{
Condition0%0/2
$document->find($_) || []
l!l
00
MC/DC0%0/1
$document->find($_) || []
$document->find($_)
Truth table0%0/2
A
A= $document->find($_)
Aresult
11
00
183 PPI::Token::Regexp::Match
184 PPI::Token::Regexp::Substitute
185 PPI::Token::QuoteLike::Regexp
186 } );
187 }
188  
189 # Find out if the subroutine named in $name is called in the given $regexp.
190 # This could happen either by an explicit s/.../.../e, or by interpolation
191 # (i.e. @{[...]} ).
192 0 ▶sub _find_sub_usage_in_regexp {
Subroutine _find_sub_usage_in_regexp: not called CC=11 SCAR=48.8
193 0 my ( $name, $regexp, $document ) = @_;
194  
195 0 ▶ my $ppix = $document->ppix_regexp_from_element( $regexp ) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $ppix = $document->ppix_regexp_from_element($regexp) or return 0 0 0
196 0 ▶ $ppix->failures() and return;
Branch: 1 branch
BranchTrueFalseTotal
$ppix->failures and return 0 0 0
197  
198 0 ▶ foreach my $code ( @{ $ppix->find( 'PPIx::Regexp::Token::Code' ) || [] } ) {
Condition0%0/2
$ppix->find('PPIx::Regexp::Token::Code') || []
l!l
00
MC/DC0%0/1
$ppix->find('PPIx::Regexp::Token::Code') || []
$ppix->find('PPIx::Regexp::Token::Code')
Truth table0%0/2
A
A= $ppix->find('PPIx::Regexp::Token::Code')
Aresult
11
00
199 0 ▶ my $doc = $code->ppi() or next;
Branch: 1 branch
BranchTrueFalseTotal
my $doc = $code->ppi or next 0 0 0
200  
201 0 ▶ foreach my $word ( @{ $doc->find( 'PPI::Token::Word' ) || [] } ) {
Condition0%0/2
$doc->find('PPI::Token::Word') || []
l!l
00
MC/DC0%0/1
$doc->find('PPI::Token::Word') || []
$doc->find('PPI::Token::Word')
Truth table0%0/2
A
A= $doc->find('PPI::Token::Word')
Aresult
11
00
202 0 ▶ $name eq $word->content() or next;
Branch: 1 branch
BranchTrueFalseTotal
$name eq $word->content or next 0 0 0
203 0 ▶ is_function_call( $word )
Branch: 1 branch
BranchTrueFalseTotal
is_function_call($word) or is_method_call($word) or next 0 0 0
Condition0%0/3
is_function_call($word) or is_method_call($word)
l!l&&r!l&&!r
000
MC/DC0%0/2
is_function_call($word) or is_method_call($word)
is_function_call($word) is_method_call($word)
Truth table0%0/3
A or B
A= is_function_call($word)B= is_method_call($word)
ABresult
1X1
011
000
204 or is_method_call( $word )
205 or next;
206 0 return $TRUE;
207 }
208  
209 }
210  
211 0 return;
212 }
213  
214 # Find out if the subroutine defined in $elem handles an overloaded operator.
215 # We recognize both string literals (the usual form) and words (in case
216 # someone perversely followed the subroutine name by a fat comma). We ignore
217 # the '\&_foo' construction, since _find_sub_reference_in_document() should
218 # find this.
219 0 ▶sub _find_sub_overload_in_document {
Subroutine _find_sub_overload_in_document: not called CC=11 SCAR=48.8
220 0 my ( $elem, $document ) = @_;
221  
222 0 my $name = $elem->name();
223  
224 0 ▶ if ( my $found = $document->find( 'PPI::Statement::Include' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $found = $document->find("PPI::Statement::Include")) 0 0 0
225 0 foreach my $usage ( @{ $found } ) {
226 0 ▶ 'overload' eq $usage->module() or next;
Branch: 1 branch
BranchTrueFalseTotal
"overload" eq $usage->module or next 0 0 0
227 0 my $inx;
228 0 foreach my $arg ( _get_include_arguments( $usage ) ) {
229 0 ▶ $inx++ % 2 or next;
Branch: 1 branch
BranchTrueFalseTotal
$inx++ % 2 or next 0 0 0
230 0 ▶ @{ $arg } == 1 or next;
Branch: 1 branch
BranchTrueFalseTotal
@{$arg;} == 1 or next 0 0 0
231 0 my $element = $arg->[0];
232  
233 0 ▶ if ( $element->isa( 'PPI::Token::Quote' ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($element->isa('PPI::Token::Quote')) { } 0 0 0
elsif ($element->isa('PPI::Token::Word')) { } 0 0 0
234 0 ▶ $element->string() eq $name and return $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$element->string eq $name and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
235 } elsif ( $element->isa( 'PPI::Token::Word' ) ) {
236 0 ▶ $element->content() eq $name and return $TRUE;
Branch: 1 branch
BranchTrueFalseTotal
$element->content eq $name and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
237 }
238 }
239 }
240 }
241  
242 0 return;
243 }
244  
245 # Find things of the form '&_foo'. This includes both references proper (i.e.
246 # '\&foo'), calls using the sigil, and gotos. The latter two do not count if
247 # inside the subroutine itself.
248 0 ▶sub _find_sub_reference_in_document {
Subroutine _find_sub_reference_in_document: not called CC=13 SCAR=52.0
249 0 my ( $elem, $document ) = @_;
250  
251 0 my $start_token = $elem->first_token();
252 0 my $finish_token = $elem->last_token();
253 0 my $symbol = q<&> . $elem->name();
254  
255 0 ▶ if ( my $found = $document->find( 'PPI::Token::Symbol' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $found = $document->find("PPI::Token::Symbol")) 0 0 0
256 0 foreach my $usage ( @{ $found } ) {
257 0 ▶ $symbol eq $usage->content() or next;
Branch: 1 branch
BranchTrueFalseTotal
$symbol eq $usage->content or next 0 0 0
258  
259 0 my $prior = $usage->sprevious_sibling();
260 0 ▶ $prior
Branch: 1 branch
BranchTrueFalseTotal
$prior and $prior->isa("PPI::Token::Cast") and "\\" eq $prior->content and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
Condition0%0/6
$prior and $prior->isa("PPI::Token::Cast") and "\\" eq $prior->content
!ll&&!rl&&r
000
$prior and $prior->isa("PPI::Token::Cast")
!ll&&!rl&&r
000
MC/DC0%0/3
$prior and $prior->isa("PPI::Token::Cast") and "\\" eq $prior->content
$prior $prior->isa("PPI::Token::Cast") "\\" eq $prior->content
Truth table0%0/4
A and B and C
A= $priorB= $prior->isa("PPI::Token::Cast")C= "\\" eq $prior->content
ABCresult
0XX0
10X0
1100
1111
261 and $prior->isa( 'PPI::Token::Cast' )
262 and q<\\> eq $prior->content()
263 and return $TRUE;
264  
265 0 ▶ is_function_call( $usage )
Branch: 1 branch
BranchTrueFalseTotal
is_function_call($usage) or $prior and $prior->isa("PPI::Token::Word") and "goto" eq $prior->content or next 0 0 0
Condition0%0/9
is_function_call($usage) or $prior and $prior->isa("PPI::Token::Word") and "goto" eq $prior->content
l!l&&r!l&&!r
000
$prior and $prior->isa("PPI::Token::Word") and "goto" eq $prior->content
!ll&&!rl&&r
000
$prior and $prior->isa("PPI::Token::Word")
!ll&&!rl&&r
000
MC/DC0%0/4
is_function_call($usage) or $prior and $prior->isa("PPI::Token::Word") and "goto" eq $prior->content
is_function_call($usage) $prior $prior->isa("PPI::Token::Word") "goto" eq $prior->content
Truth table0%0/5
A or B and C and D
A= is_function_call($usage)B= $priorC= $prior->isa("PPI::Token::Word")D= "goto" eq $prior->content
ABCDresult
1XXX1
01111
00XX0
010X0
01100
266 or $prior
267 and $prior->isa( 'PPI::Token::Word' )
268 and 'goto' eq $prior->content()
269 or next;
270  
271 0 ▶ _compare_token_locations( $usage, $start_token ) < 0
Branch: 1 branch
BranchTrueFalseTotal
_compare_token_locations($usage, $start_token) < 0 and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
272 and return $TRUE;
273 0 ▶ _compare_token_locations( $finish_token, $usage ) < 0
Branch: 1 branch
BranchTrueFalseTotal
_compare_token_locations($finish_token, $usage) < 0 and return $Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines::TRUE 0 0 0
274 and return $TRUE;
275 }
276 }
277  
278 0 return;
279 }
280  
281 # Expand the given element, losing any brackets along the way. This is
282 # intended to be used to flatten the argument list of 'use overload'.
283 0 ▶sub _expand_element {
Subroutine _expand_element: not called CC=3 SCAR=24.8
284 0 my ( $element ) = @_;
285 $element->isa( 'PPI::Node' )
286 0 ▶ and return ( map { _expand_element( $_ ) } $_->children() );
Branch: 1 branch
BranchTrueFalseTotal
$element->isa("PPI::Node") and return map({_expand_element($_);} $_->children) 0 0 0
287 0 ▶ $element->significant() and return $element;
Branch: 1 branch
BranchTrueFalseTotal
$element->significant and return $element 0 0 0
288 0 return;
289 }
290  
291 # Given an include statement, return its arguments. The return is a flattened
292 # list of lists of tokens, each list of tokens representing an argument.
293 0 ▶sub _get_include_arguments {
Subroutine _get_include_arguments: not called CC=6 SCAR=37.4
294 0 my ($include) = @_;
295  
296 # If there are no arguments, just return. We flatten the list because
297 # someone might use parens to define it.
298 0 ▶ my @arguments = map { _expand_element( $_ ) } $include->arguments()
Branch: 1 branch
BranchTrueFalseTotal
my(@arguments) = map({_expand_element($_);} $include->arguments) or return 0 0 0
299 or return;
300  
301 0 my @elements;
302 0 my $inx = 0;
303 0 foreach my $element ( @arguments ) {
304 0 ▶ if ( $element->isa( 'PPI::Token::Operator' ) &&
Branch: 1 branch
BranchTrueFalseTotal
if ($element->isa('PPI::Token::Operator') and $IS_COMMA{$element->content}) { } 0 0 0
Condition0%0/3
$element->isa("PPI::Token::Operator") and $IS_COMMA{$element->content}
!ll&&!rl&&r
000
MC/DC0%0/2
$element->isa("PPI::Token::Operator") and $IS_COMMA{$element->content}
$element->isa("PPI::Token::Operator") $IS_COMMA{$element->content}
Truth table0%0/3
A and B
A= $element->isa("PPI::Token::Operator")B= $IS_COMMA{$element->content}
ABresult
0X0
100
111
305 $IS_COMMA{$element->content()} ) {
306 0 $inx++;
307 } else {
308 0 ▶ push @{ $elements[$inx] ||= [] }, $element;
Condition0%0/2
$elements[$inx] ||= []
l!l
00
MC/DC0%0/1
$elements[$inx] ||= []
$elements[$inx]
Truth table0%0/2
A
A= $elements[$inx]
Aresult
11
00
309 }
310 }
311  
312 0 return @elements;
313 }
314  
315 40 1;
316  
317 __END__
« lib/Perl/Critic/Policy/ControlStructures/ProhibitMutatingListFunctions.pm ↑ Summary lib/Perl/Critic/Policy/ErrorHandling/RequireCheckingReturnValueOfEval.pm »