Policy/Compatibility/PerlMinimumVersionAndWhy.pm

filter: Statementstmt 16.3% 59 / 360 Branchbran 0.7% 1 / 138 Conditioncond 0.0% 0 / 219 MC/DCmcdc 0.0% 0 / 106 Subroutinesub 19.2% 16 / 83 Podpod 66.6% 2 / 3 totaltotal 8.5% 78 / 909 CC 149 SCAR 37.7
CC
149
Cov
8%
__ANON__
132.0
_arg_is_array_elem
110.0
__ANON__
110.0
CRAP 43.2
↑ Summary Policy/ValuesAndExpressions/ProhibitUnknownBackslash.pm »
1 # Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde
2  
3 # Perl-Critic-Pulp is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by the
5 # Free Software Foundation; either version 3, or (at your option) any later
6 # version.
7 #
8 # Perl-Critic-Pulp is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 # for more details.
12 #
13 # You should have received a copy of the GNU General Public License along
14 # with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
15  
16 package Perl::Critic::Policy::Compatibility::PerlMinimumVersionAndWhy;
17 40 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 40 ▶use version (); # but don't import qv()
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # 1.208 for PPI::Token::QuoteLike::Regexp get_modifiers()
23 40 ▶use PPI 1.208;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # 1.084 for Perl::Critic::Document highest_explicit_perl_version()
26 40 ▶use Perl::Critic::Policy 1.084;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 40 ▶use base 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 40 ▶use Perl::Critic::Utils qw(parse_arg_list);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 40 ▶use Perl::Critic::Pulp::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 # uncomment this to run the ### lines
32 # use Smart::Comments;
33  
34 40 our $VERSION = 100;
35  
36 40 ▶use constant supported_parameters =>
Subroutine BEGIN: called CC=1 SCAR=0.0
37 ({ name => 'above_version',
38 description => 'Check only things above this version of Perl.',
39 behavior => 'string',
40 parser => \&Perl::Critic::Pulp::Utils::parameter_parse_version,
41 },
42 { name => 'skip_checks',
43 description => 'Version checks to skip (space separated list).',
44 behavior => 'string',
45 40 });
46 40 ▶use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOW;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 40 ▶use constant default_themes => qw(pulp compatibility);
Subroutine BEGIN: called CC=1 SCAR=0.0
48 40 ▶use constant applies_to => 'PPI::Document';
Subroutine BEGIN: called CC=1 SCAR=0.0
49  
50  
51 2 ▶sub initialize_if_enabled {
Subroutine initialize_if_enabled: called CC=2 SCAR=8.4
Pod documented
52 2 my ($self, $config) = @_;
53 # ask that Perl::MinimumVersion is available and still has its
54 # undocumented %CHECKS to mangle below
55 2 ▶ eval { require Perl::MinimumVersion;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Perl::MinimumVersion; scalar %Perl::MinimumVersion::CHECKS } } or return 0 0 2 2
56 0 scalar %Perl::MinimumVersion::CHECKS }
57 or return 0;
58  
59 0 _setup_extra_checks();
60 }
61  
62 0 ▶sub violates {
Subroutine violates: not called CC=11 SCAR=46.9
Pod documented
63 0 my ($self, $document) = @_;
64  
65 0 my %skip_checks;
66 0 ▶ if (defined (my $skip_checks = $self->{_skip_checks})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $skip_checks = $self->{"_skip_checks"})) 0 0 0
67 0 @skip_checks{split / /, $self->{_skip_checks}} = (); # hash slice
68 }
69  
70 0 my $pmv = Perl::MinimumVersion->new ($document);
71 0 my $config_above_version = $self->{'_above_version'};
72 0 my $explicit_version = _highest_explicit_perl_version($document);
73  
74 0 my @violations;
75 0 foreach my $check (sort keys %Perl::MinimumVersion::CHECKS) {
76 0 ▶ next if exists $skip_checks{$check};
Branch: 1 branch
BranchTrueFalseTotal
if exists $skip_checks{$check} 0 0 0
77 0 ▶ next if $check eq '_constant_hash'; # better by ConstantPragmaHash
Branch: 1 branch
BranchTrueFalseTotal
if $check eq "_constant_hash" 0 0 0
78 # next if $check =~ /_pragmas$/; # usually impossible in earlier
79 0 ▶ next if $check =~ /_modules$/; # wrong for dual-life stuff
Branch: 1 branch
BranchTrueFalseTotal
if $check =~ /_modules$/ 0 0 0
80  
81 0 my $check_version = $Perl::MinimumVersion::CHECKS{$check};
82 0 ▶ next if (defined $explicit_version
Branch: 1 branch
BranchTrueFalseTotal
if defined $explicit_version and $check_version <= $explicit_version 0 0 0
Condition0%0/3
defined $explicit_version and $check_version <= $explicit_version
!ll&&!rl&&r
000
MC/DC0%0/2
defined $explicit_version and $check_version <= $explicit_version
defined $explicit_version $check_version <= $explicit_version
Truth table0%0/3
A and B
A= defined $explicit_versionB= $check_version <= $explicit_version
ABresult
0X0
100
111
83 && $check_version <= $explicit_version);
84 0 ▶ next if (defined $config_above_version
Branch: 1 branch
BranchTrueFalseTotal
if defined $config_above_version and $check_version <= $config_above_version 0 0 0
Condition0%0/3
defined $config_above_version and $check_version <= $config_above_version
!ll&&!rl&&r
000
MC/DC0%0/2
defined $config_above_version and $check_version <= $config_above_version
defined $config_above_version $check_version <= $config_above_version
Truth table0%0/3
A and B
A= defined $config_above_versionB= $check_version <= $config_above_version
ABresult
0X0
100
111
85 && $check_version <= $config_above_version);
86 ### $check
87  
88 0 ▶ my $elem = do {
Condition0%0/2
do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} local *PPI::Node::find_any = \&PPI::Node::find_first; $pmv->$check } || (next)
l!l
00
MC/DC0%0/1
do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} local *PPI::Node::find_any = \&PPI::Node::find_first; $pmv->$check } || (next)
do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} local *PPI::Node::find_any = \&PPI::Node::find_first; $pmv->$check }
Truth table0%0/2
A
A= do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x15\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} local *PPI::Node::find_any = \&PPI::Node::find_first; $pmv->$check }
Aresult
11
00
89 40 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
90 0 local *PPI::Node::find_any = \&PPI::Node::find_first;
91 0 $pmv->$check
92 } || next;
93 # require Data::Dumper;
94 # print Data::Dumper::Dumper($elem);
95 # print $elem->location,"\n";
96 0 push @violations,
97 $self->violation ("$check requires $check_version",
98 '',
99 $elem);
100 }
101 0 return @violations;
102 }
103  
104 40 my $v5010 = version->new('5.010');
105  
106 # Some controversy:
107 # https://github.com/Perl-Critic/Perl-Critic/issues/270
108 # http://elliotlovesperl.com/2009/05/17/the-problem-with-modernperl/
109 #
110 0 ▶sub _highest_explicit_perl_version {
Subroutine _highest_explicit_perl_version: not called CC=3 SCAR=24.8
111 0 my ($document) = @_;
112 ### _highest_explicit_perl_version() ...
113 0 my $ver = $document->highest_explicit_perl_version;
114 0 ▶ if ($ver < $v5010
Branch: 1 branch
BranchTrueFalseTotal
if ($ver < $v5010 and Perl::Critic::Policy::Compatibility::Gtk2Constants::_document_uses_module($document, "Modern::Perl")) 0 0 0
Condition0%0/3
$ver < $v5010 and Perl::Critic::Policy::Compatibility::Gtk2Constants::_document_uses_module($document, "Modern::Perl")
!ll&&!rl&&r
000
MC/DC0%0/2
$ver < $v5010 and Perl::Critic::Policy::Compatibility::Gtk2Constants::_document_uses_module($document, "Modern::Perl")
$ver < $v5010 Perl::Critic::Policy::Compatibility::Gtk2Constants::_document_uses_module($document, "Modern::Perl")
Truth table0%0/3
A and B
A= $ver < $v5010B= Perl::Critic::Policy::Compatibility::Gtk2Constants::_document_uses_module($document, "Modern::Perl")
ABresult
0X0
100
111
115 && Perl::Critic::Policy::Compatibility::Gtk2Constants::_document_uses_module($document,'Modern::Perl')) {
116 ### increase to 5.010 ...
117 0 $ver = $v5010;
118 }
119 0 return $ver;
120 }
121  
122  
123 #---------------------------------------------------------------------------
124 # Crib note: $document->find_first wanted func returning undef means the
125 # element is unwanted and also don't descend into its sub-elements.
126 #
127  
128 0 ▶sub _setup_extra_checks {
Subroutine _setup_extra_checks: not called CC=3 SCAR=24.8
129  
130 # 5.12.0
131 0 my $v5012 = version->new('5.012');
132 0 $Perl::MinimumVersion::CHECKS{_Pulp__keys_of_array} = $v5012;
133 0 $Perl::MinimumVersion::CHECKS{_Pulp__values_of_array} = $v5012;
134 0 $Perl::MinimumVersion::CHECKS{_Pulp__each_of_array} = $v5012;
135  
136 # 5.10.0
137 0 ▶ unless (eval { Perl::MinimumVersion->VERSION(1.28); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { "Perl::MinimumVersion"->VERSION("1.28"); 1 } }) 0 0 0
138 # fixed in 1.28 up
139 0 $Perl::MinimumVersion::CHECKS{_Pulp__5010_magic__fix} = $v5010;
140 0 $Perl::MinimumVersion::CHECKS{_Pulp__5010_operators__fix} = $v5010;
141 }
142 0 $Perl::MinimumVersion::CHECKS{_Pulp__5010_qr_m_propagate_properly} = $v5010;
143 0 $Perl::MinimumVersion::CHECKS{_Pulp__5010_stacked_filetest} = $v5010;
144  
145 # 5.8.0
146 0 my $v5008 = version->new('5.008');
147 0 $Perl::MinimumVersion::CHECKS{_Pulp__fat_comma_across_newline} = $v5008;
148 0 $Perl::MinimumVersion::CHECKS{_Pulp__eval_line_directive_first_thing} = $v5008;
149  
150 # 5.6.0
151 0 my $v5006 = version->new('5.006');
152 0 $Perl::MinimumVersion::CHECKS{_Pulp__exists_subr} = $v5006;
153 0 $Perl::MinimumVersion::CHECKS{_Pulp__exists_array_elem} = $v5006;
154 0 $Perl::MinimumVersion::CHECKS{_Pulp__delete_array_elem} = $v5006;
155 0 $Perl::MinimumVersion::CHECKS{_Pulp__0b_number} = $v5006;
156 0 $Perl::MinimumVersion::CHECKS{_Pulp__syswrite_length_optional} = $v5006;
157 0 $Perl::MinimumVersion::CHECKS{_Pulp__open_my_filehandle} = $v5006;
158 0 $Perl::MinimumVersion::CHECKS{_Pulp__var_method_without_parens} = $v5006;
159  
160 # 5.005
161 0 my $v5005 = version->new('5.005');
162 0 ▶ unless (exists
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $Perl::MinimumVersion::CHECKS{"_bareword_ends_with_double_colon"}) 0 0 0
163 $Perl::MinimumVersion::CHECKS{_bareword_ends_with_double_colon}) {
164 # adopted into Perl::MinimumVersion 1.28
165 0 $Perl::MinimumVersion::CHECKS{_Pulp__bareword_double_colon} = $v5005;
166 }
167 0 $Perl::MinimumVersion::CHECKS{_Pulp__my_list_with_undef} = $v5005;
168  
169 # 5.004
170 0 my $v5004 = version->new('5.004');
171 0 $Perl::MinimumVersion::CHECKS{_Pulp__special_literal__PACKAGE__} = $v5004;
172 0 $Perl::MinimumVersion::CHECKS{_Pulp__use_version_number} = $v5004;
173 0 $Perl::MinimumVersion::CHECKS{_Pulp__for_loop_variable_using_my} = $v5004;
174 0 $Perl::MinimumVersion::CHECKS{_Pulp__arrow_coderef_call} = $v5004;
175 0 $Perl::MinimumVersion::CHECKS{_Pulp__sysseek_builtin} = $v5004;
176  
177 # UNIVERSAL.pm
178 0 $Perl::MinimumVersion::CHECKS{_Pulp__UNIVERSAL_methods_5004} = $v5004;
179 0 $Perl::MinimumVersion::CHECKS{_Pulp__UNIVERSAL_methods_5010} = $v5010;
180  
181 # pack()/unpack()
182 0 $Perl::MinimumVersion::CHECKS{_Pulp__pack_format_5004} = $v5004;
183 0 $Perl::MinimumVersion::CHECKS{_Pulp__pack_format_5006} = $v5006;
184 0 $Perl::MinimumVersion::CHECKS{_Pulp__pack_format_5008} = $v5008;
185 0 $Perl::MinimumVersion::CHECKS{_Pulp__pack_format_5010} = $v5010;
186 }
187  
188 {
189 # Perl::MinimumVersion prior to 1.28 had 'PPI::Token::Operator' and
190 # 'PPI::Token::Magic' swapped between the respective operator/magic tests
191  
192 package Perl::MinimumVersion;
193 40 ▶ use vars qw(%MATCHES);
Subroutine BEGIN: called CC=1 SCAR=0.0
194 0 ▶ sub _Pulp__5010_operators__fix {
Subroutine _Pulp__5010_operators__fix: not called CC=1 SCAR=6.9
195 shift->Document->find_first
196 0 ▶ (sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
197 $_[1]->isa('PPI::Token::Operator')
198 and
199 0 ▶ $MATCHES{_perl_5010_operators}->{$_[1]->content};
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Operator") and $Perl::MinimumVersion::MATCHES{"_perl_5010_operators"}{$_[1]->content} 0 0 0
200 0 } );
201 }
202 0 ▶ sub _Pulp__5010_magic__fix {
Subroutine _Pulp__5010_magic__fix: not called CC=1 SCAR=6.9
203 shift->Document->find_first
204 0 ▶ (sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
205 $_[1]->isa('PPI::Token::Magic')
206 and
207 0 ▶ $MATCHES{_perl_5010_magic}->{$_[1]->content};
Branch: 1 branch
BranchTrueFalseTotal
$_[1]->isa("PPI::Token::Magic") and $Perl::MinimumVersion::MATCHES{"_perl_5010_magic"}{$_[1]->content} 0 0 0
208 0 } );
209 }
210 }
211  
212 40 ▶sub Perl::MinimumVersion::_Pulp__5010_qr_m_propagate_properly {
Subroutine _Pulp__5010_qr_m_propagate_properly: not called CC=1 SCAR=5.6
213 0 my ($pmv) = @_;
214 ### _Pulp__5010_qr_m_propagate_properly() check ...
215 $pmv->Document->find_first
216 0 ▶ (sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
217 0 my ($document, $elem) = @_;
218 0 ▶ $elem->isa('PPI::Token::QuoteLike::Regexp') || return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::QuoteLike::Regexp") or return 0 0 0 0
219 0 my %modifiers = $elem->get_modifiers;
220 ### content: $elem->content
221 ### modifiers: \%modifiers
222 0 ▶ return ($modifiers{'m'} ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$modifiers{'m'} ? : 0 0 0
223 0 });
224 }
225  
226 # new in 5.010 as described in perlfunc.pod
227 0 ▶sub Perl::MinimumVersion::_Pulp__5010_stacked_filetest {
Subroutine _Pulp__5010_stacked_filetest: not called CC=1 SCAR=6.9
228 0 my ($pmv) = @_;
229 ### _Pulp__5010_stacked_filetest() check ...
230 $pmv->Document->find_first
231 0 ▶ (sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
232 0 my ($document, $elem) = @_;
233 0 ▶ return (_elem_is_filetest_operator($elem) # -X
Branch: 1 branch
BranchTrueFalseTotal
_elem_is_filetest_operator($elem) && ($elem = $elem->snext_sibling) && _elem_is_filetest_operator($elem) ? : 0 0 0
Condition0%0/6
_elem_is_filetest_operator($elem) and $elem = $elem->snext_sibling and _elem_is_filetest_operator($elem)
!ll&&!rl&&r
000
_elem_is_filetest_operator($elem) and $elem = $elem->snext_sibling
!ll&&!rl&&r
000
MC/DC0%0/3
_elem_is_filetest_operator($elem) and $elem = $elem->snext_sibling and _elem_is_filetest_operator($elem)
_elem_is_filetest_operator($elem) $elem = $elem->snext_sibling _elem_is_filetest_operator($elem)
Truth table0%0/4
A and B and C
A= _elem_is_filetest_operator($elem)B= $elem = $elem->snext_siblingC= _elem_is_filetest_operator($elem)
ABCresult
0XX0
10X0
1100
1111
234 && ($elem = $elem->snext_sibling) # has a next sibling
235 && _elem_is_filetest_operator($elem) # -X
236 ? 1 : 0);
237 0 });
238 }
239 # $elem is a PPI::Element
240 # Return true if it's a -X operator.
241 0 ▶sub _elem_is_filetest_operator {
Subroutine _elem_is_filetest_operator: not called CC=2 SCAR=17.9
242 0 my ($elem) = @_;
243 0 ▶ return ($elem->isa('PPI::Token::Operator')
Condition0%0/3
$elem->isa('PPI::Token::Operator') && $elem =~ /^-./
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa('PPI::Token::Operator') && $elem =~ /^-./
$elem->isa('PPI::Token::Operator') $elem =~ /^-./
Truth table0%0/3
A && B
A= $elem->isa('PPI::Token::Operator')B= $elem =~ /^-./
ABresult
0X0
100
111
244 && $elem =~ /^-./);
245 }
246  
247  
248 #-----------------------------------------------------------------------------
249 # foo \n => fat comma across newline new in 5.8.0
250 # extra code in 5.8 toke.c under comment "not a keyword" checking for =>
251 #
252  
253 0 ▶sub Perl::MinimumVersion::_Pulp__fat_comma_across_newline {
Subroutine _Pulp__fat_comma_across_newline: not called CC=1 SCAR=6.9
254 0 my ($pmv) = @_;
255 ### _Pulp__fat_comma_across_newline() check
256 $pmv->Document->find_first
257 0 ▶ (sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
258 0 my ($document, $elem) = @_;
259 ### elem: "$elem"
260 0 ▶ if ($elem->isa('PPI::Token::Operator')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Operator") and $elem->content eq "=>") 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Operator") and $elem->content eq "=>"
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Operator") and $elem->content eq "=>"
$elem->isa("PPI::Token::Operator") $elem->content eq "=>"
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Operator")B= $elem->content eq "=>"
ABresult
0X0
100
111
261 && $elem->content eq '=>') {
262 0 my ($prev, $saw_newline) = sprevious_sibling_and_newline($elem);
263 ### prev: "$prev"
264 ### $saw_newline
265 0 ▶ if ($saw_newline
Branch: 1 branch
BranchTrueFalseTotal
if ($saw_newline and $prev and $prev->isa("PPI::Token::Word") and not $prev =~ /^-/ and not Perl::Critic::Utils::is_method_call($prev)) 0 0 0
Condition0%0/12
$saw_newline and $prev and $prev->isa("PPI::Token::Word") and not $prev =~ /^-/ and not Perl::Critic::Utils::is_method_call($prev)
!ll&&!rl&&r
000
$saw_newline and $prev and $prev->isa("PPI::Token::Word") and not $prev =~ /^-/
!ll&&!rl&&r
000
$saw_newline and $prev and $prev->isa("PPI::Token::Word")
!ll&&!rl&&r
000
$saw_newline and $prev
!ll&&!rl&&r
000
MC/DC0%0/5
$saw_newline and $prev and $prev->isa("PPI::Token::Word") and not $prev =~ /^-/ and not Perl::Critic::Utils::is_method_call($prev)
$saw_newline $prev $prev->isa("PPI::Token::Word") not $prev =~ /^-/ not Perl::Critic::Utils::is_method_call($prev)
Truth table0%0/6
A and B and C and not(D) and not(E)
A= $saw_newlineB= $prevC= $prev->isa("PPI::Token::Word")D= not $prev =~ /^-/E= not Perl::Critic::Utils::is_method_call($prev)
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
266 && $prev
267 && $prev->isa('PPI::Token::Word')
268 && $prev !~ /^-/ # -foo self-quotes
269 && ! Perl::Critic::Utils::is_method_call($prev)) { # ->foo
270 0 return 1; # found
271 }
272 }
273 0 return 0; # continue searching
274 0 });
275 }
276  
277 0 ▶sub sprevious_sibling_and_newline {
Subroutine sprevious_sibling_and_newline: not called CC=5 SCAR=34.0
Pod undocumented
278 0 my ($elem) = @_;
279 ### sprevious_sibling_and_newline()
280 0 my $saw_newline;
281 0 for (;;) {
282 0 ▶ $elem = $elem->previous_sibling || last;
Condition0%0/2
$elem->previous_sibling || (last)
l!l
00
MC/DC0%0/1
$elem->previous_sibling || (last)
$elem->previous_sibling
Truth table0%0/2
A
A= $elem->previous_sibling
Aresult
11
00
283 0 ▶ if ($elem->isa('PPI::Token::Whitespace')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Whitespace')) { } 0 0 0
elsif ($elem->isa('PPI::Token::Comment')) { } 0 0 0
284 0 ▶ $saw_newline ||= ($elem->content =~ /\n/);
Condition0%0/3
$saw_newline ||= $elem->content =~ /\n/
l!l&&r!l&&!r
000
MC/DC0%0/2
$saw_newline ||= $elem->content =~ /\n/
$saw_newline $elem->content =~ /\n/
Truth table0%0/3
A ||= B
A= $saw_newlineB= $elem->content =~ /\n/
ABresult
1X1
011
000
285 } elsif ($elem->isa('PPI::Token::Comment')) {
286 0 $saw_newline = 1;
287 } else {
288 0 last;
289 }
290 }
291 0 return ($elem, $saw_newline);
292 }
293  
294 #-----------------------------------------------------------------------------
295  
296 # delete $array[0] and exists $array[0] new in 5.6.0
297 # two functions so the "exists" or "delete" appears in the check name
298 #
299 0 ▶sub Perl::MinimumVersion::_Pulp__exists_array_elem {
Subroutine _Pulp__exists_array_elem: not called CC=1 SCAR=6.9
300 0 my ($pmv) = @_;
301 ### _Pulp__exists_array_elem() check
302 0 return _exists_or_delete_array_elem ($pmv, 'exists');
303 }
304 0 ▶sub Perl::MinimumVersion::_Pulp__delete_array_elem {
Subroutine _Pulp__delete_array_elem: not called CC=1 SCAR=6.9
305 0 my ($pmv) = @_;
306 ### _Pulp__delete_array_elem() check
307 0 return _exists_or_delete_array_elem ($pmv, 'delete');
308 }
309 0 ▶sub _exists_or_delete_array_elem {
Subroutine _exists_or_delete_array_elem: not called CC=1 SCAR=6.9
310 0 my ($pmv, $which) = @_;
311 ### _exists_or_delete_array_elem()
312 $pmv->Document->find_first
313 0 ▶ (sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
314 0 my ($document, $elem) = @_;
315 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq $which and Perl::Critic::Utils::is_function_call($elem) and _arg_is_array_elem($elem->snext_sibling)) { } 0 0 0
Condition0%0/9
$elem->isa("PPI::Token::Word") and $elem eq $which and Perl::Critic::Utils::is_function_call($elem) and _arg_is_array_elem($elem->snext_sibling)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq $which and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq $which
!ll&&!rl&&r
000
MC/DC0%0/4
$elem->isa("PPI::Token::Word") and $elem eq $which and Perl::Critic::Utils::is_function_call($elem) and _arg_is_array_elem($elem->snext_sibling)
$elem->isa("PPI::Token::Word") $elem eq $which Perl::Critic::Utils::is_function_call($elem) _arg_is_array_elem($elem->snext_sibling)
Truth table0%0/5
A and B and C and D
A= $elem->isa("PPI::Token::Word")B= $elem eq $whichC= Perl::Critic::Utils::is_function_call($elem)D= _arg_is_array_elem($elem->snext_sibling)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
316 && $elem eq $which
317 && Perl::Critic::Utils::is_function_call($elem)
318 && _arg_is_array_elem($elem->snext_sibling)) {
319 0 return 1;
320 } else {
321 0 return 0;
322 }
323 0 });
324 }
325 0 ▶sub _arg_is_array_elem {
Subroutine _arg_is_array_elem: not called CC=10 SCAR=47.0
326 0 my ($elem) = @_;
327 ### _arg_is_array_elem: "$elem"
328  
329 0 ▶ (($elem = _descend_through_lists($elem))
Branch: 1 branch
BranchTrueFalseTotal
$elem = _descend_through_lists($elem) and $elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\$" and $elem = $elem->snext_sibling or return 0 0 0 0
Condition0%0/9
$elem = _descend_through_lists($elem) and $elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\$" and $elem = $elem->snext_sibling
!ll&&!rl&&r
000
$elem = _descend_through_lists($elem) and $elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\$"
!ll&&!rl&&r
000
$elem = _descend_through_lists($elem) and $elem->isa("PPI::Token::Symbol")
!ll&&!rl&&r
000
MC/DC0%0/4
$elem = _descend_through_lists($elem) and $elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\$" and $elem = $elem->snext_sibling
$elem = _descend_through_lists($elem) $elem->isa("PPI::Token::Symbol") $elem->raw_type eq "\$" $elem = $elem->snext_sibling
Truth table0%0/5
A and B and C and D
A= $elem = _descend_through_lists($elem)B= $elem->isa("PPI::Token::Symbol")C= $elem->raw_type eq "\$"D= $elem = $elem->snext_sibling
ABCDresult
0XXX0
10XX0
110X0
11100
11111
330 && $elem->isa('PPI::Token::Symbol')
331 && $elem->raw_type eq '$'
332 && ($elem = $elem->snext_sibling))
333 or return 0;
334  
335 0 my $ret = 0;
336 0 for (;;) {
337 0 ▶ if ($elem->isa('PPI::Structure::Subscript')) {
Branch: 3 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Structure::Subscript')) { } 0 0 0
elsif ($elem->isa('PPI::Structure::List')) { } 0 0 0
elsif ($elem->isa('PPI::Token::Operator') and $elem eq '->') { } 0 0 0
338 # adjacent $x{key}[123]
339 0 $ret = ($elem->start eq '[');
340 } elsif ($elem->isa('PPI::Structure::List')) {
341 # $x[0]->() function call
342 0 return 0;
343 ▶ } elsif ($elem->isa('PPI::Token::Operator')
Condition0%0/3
$elem->isa("PPI::Token::Operator") and $elem eq "->"
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Operator") and $elem eq "->"
$elem->isa("PPI::Token::Operator") $elem eq "->"
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Operator")B= $elem eq "->"
ABresult
0X0
100
111
344 && $elem eq '->') {
345 # subscript ->, continue
346 } else {
347 # anything else below -> precedence, stop
348 0 last;
349 }
350 0 ▶ $elem = $elem->snext_sibling || last;
Condition0%0/2
$elem->snext_sibling || (last)
l!l
00
MC/DC0%0/1
$elem->snext_sibling || (last)
$elem->snext_sibling
Truth table0%0/2
A
A= $elem->snext_sibling
Aresult
11
00
351 }
352 ### $ret
353 0 return $ret;
354 }
355  
356 0 ▶sub _descend_through_lists {
Subroutine _descend_through_lists: not called CC=5 SCAR=34.0
357 0 my ($elem) = @_;
358 0 ▶ while ($elem
Branch: 1 branch
BranchTrueFalseTotal
if ($elem and $elem->isa("PPI::Structure::List") || $elem->isa("PPI::Statement::Expression") || $elem->isa("PPI::Statement")) 0 0 0
Condition0%0/9
$elem and $elem->isa("PPI::Structure::List") || $elem->isa("PPI::Statement::Expression") || $elem->isa("PPI::Statement")
!ll&&!rl&&r
000
$elem->isa("PPI::Structure::List") or $elem->isa("PPI::Statement::Expression") or $elem->isa("PPI::Statement")
l!l&&r!l&&!r
000
$elem->isa("PPI::Structure::List") or $elem->isa("PPI::Statement::Expression")
l!l&&r!l&&!r
000
MC/DC0%0/4
$elem and $elem->isa("PPI::Structure::List") || $elem->isa("PPI::Statement::Expression") || $elem->isa("PPI::Statement")
$elem $elem->isa("PPI::Structure::List") $elem->isa("PPI::Statement::Expression") $elem->isa("PPI::Statement")
Truth table0%0/5
A and B or C or D
A= $elemB= $elem->isa("PPI::Structure::List")C= $elem->isa("PPI::Statement::Expression")D= $elem->isa("PPI::Statement")
ABCDresult
0XXX0
10000
11XX1
101X1
10011
359 && ($elem->isa('PPI::Structure::List')
360 || $elem->isa('PPI::Statement::Expression')
361 || $elem->isa('PPI::Statement'))) {
362 0 $elem = $elem->schild(0);
363 }
364 0 return $elem;
365 }
366  
367 # exists(&subr) new in 5.6.0
368 #
369 0 ▶sub Perl::MinimumVersion::_Pulp__exists_subr {
Subroutine _Pulp__exists_subr: not called CC=1 SCAR=6.9
370 0 my ($pmv) = @_;
371 ### _Pulp__exists_subr() check
372 $pmv->Document->find_first
373 0 ▶ (sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
374 0 my ($document, $elem) = @_;
375 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq 'exists' and Perl::Critic::Utils::is_function_call($elem) and $elem = _symbol_or_list_symbol($elem->snext_sibling) and $elem->symbol_type eq '&') { } 0 0 0
Condition0%0/12
$elem->isa("PPI::Token::Word") and $elem eq "exists" and Perl::Critic::Utils::is_function_call($elem) and $elem = _symbol_or_list_symbol($elem->snext_sibling) and $elem->symbol_type eq "&"
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "exists" and Perl::Critic::Utils::is_function_call($elem) and $elem = _symbol_or_list_symbol($elem->snext_sibling)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "exists" and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "exists"
!ll&&!rl&&r
000
MC/DC0%0/5
$elem->isa("PPI::Token::Word") and $elem eq "exists" and Perl::Critic::Utils::is_function_call($elem) and $elem = _symbol_or_list_symbol($elem->snext_sibling) and $elem->symbol_type eq "&"
$elem->isa("PPI::Token::Word") $elem eq "exists" Perl::Critic::Utils::is_function_call($elem) $elem = _symbol_or_list_symbol($elem->snext_sibling) $elem->symbol_type eq "&"
Truth table0%0/6
A and B and C and D and E
A= $elem->isa("PPI::Token::Word")B= $elem eq "exists"C= Perl::Critic::Utils::is_function_call($elem)D= $elem = _symbol_or_list_symbol($elem->snext_sibling)E= $elem->symbol_type eq "&"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
376 && $elem eq 'exists'
377 && Perl::Critic::Utils::is_function_call($elem)
378 && ($elem = _symbol_or_list_symbol($elem->snext_sibling))
379 && $elem->symbol_type eq '&') {
380 0 return 1;
381 } else {
382 0 return 0;
383 }
384 0 });
385 }
386  
387 # 0b110011 binary literals new in 5.6.0
388 #
389 0 ▶sub Perl::MinimumVersion::_Pulp__0b_number {
Subroutine _Pulp__0b_number: not called CC=1 SCAR=6.9
390 0 my ($pmv) = @_;
391 ### _Pulp__0b_number() check
392 $pmv->Document->find_first
393 0 ▶ (sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
394 0 my ($document, $elem) = @_;
395 0 ▶ if ($elem->isa('PPI::Token::Number::Binary')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Number::Binary')) { } 0 0 0
396 0 return 1;
397 } else {
398 0 return 0;
399 }
400 0 });
401 }
402  
403 # syswrite($fh,$str) length optional in 5.6.0
404 #
405 0 ▶sub Perl::MinimumVersion::_Pulp__syswrite_length_optional {
Subroutine _Pulp__syswrite_length_optional: not called CC=1 SCAR=6.9
406 0 my ($pmv) = @_;
407 ### _Pulp__syswrite_length_optional() check
408 $pmv->Document->find_first
409 0 ▶ (sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
410 0 my ($document, $elem) = @_;
411 0 my @args;
412 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq 'syswrite' and Perl::Critic::Utils::is_function_call($elem) and (@args = Perl::Critic::Utils::parse_arg_list($elem)) == 2) { } 0 0 0
Condition0%0/9
$elem->isa("PPI::Token::Word") and $elem eq "syswrite" and Perl::Critic::Utils::is_function_call($elem) and (@args = Perl::Critic::Utils::parse_arg_list($elem)) == 2
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "syswrite" and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "syswrite"
!ll&&!rl&&r
000
MC/DC0%0/4
$elem->isa("PPI::Token::Word") and $elem eq "syswrite" and Perl::Critic::Utils::is_function_call($elem) and (@args = Perl::Critic::Utils::parse_arg_list($elem)) == 2
$elem->isa("PPI::Token::Word") $elem eq "syswrite" Perl::Critic::Utils::is_function_call($elem) (@args = Perl::Critic::Utils::parse_arg_list($elem)) == 2
Truth table0%0/5
A and B and C and D
A= $elem->isa("PPI::Token::Word")B= $elem eq "syswrite"C= Perl::Critic::Utils::is_function_call($elem)D= (@args = Perl::Critic::Utils::parse_arg_list($elem)) == 2
ABCDresult
0XXX0
10XX0
110X0
11100
11111
413 && $elem eq 'syswrite'
414 && Perl::Critic::Utils::is_function_call($elem)
415 && (@args = Perl::Critic::Utils::parse_arg_list($elem)) == 2) {
416 0 return 1;
417 } else {
418 0 return 0;
419 }
420 0 });
421 }
422  
423 # open(my $fh,...) auto-creating a handle glob new in 5.6.0
424 #
425 40 my %open_func = (open => 1,
426 opendir => 1,
427 pipe => 2,
428 socketpair => 2,
429 sysopen => 1,
430 socket => 1,
431 accept => 1);
432 0 ▶sub Perl::MinimumVersion::_Pulp__open_my_filehandle {
Subroutine _Pulp__open_my_filehandle: not called CC=1 SCAR=6.9
433 0 my ($pmv) = @_;
434 ### _Pulp__open_my_filehandle() check
435 $pmv->Document->find_first
436 0 ▶ (sub {
Subroutine __ANON__: not called CC=11 SCAR=48.8
437 0 my ($document, $elem) = @_;
438 0 my ($count, $my, $fh);
439 0 ▶ unless ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
unless ($elem->isa("PPI::Token::Word") and $count = $open_func{$elem} and Perl::Critic::Utils::is_function_call($elem)) 0 0 0
Condition0%0/6
$elem->isa("PPI::Token::Word") and $count = $open_func{$elem} and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $count = $open_func{$elem}
!ll&&!rl&&r
000
MC/DC0%0/3
$elem->isa("PPI::Token::Word") and $count = $open_func{$elem} and Perl::Critic::Utils::is_function_call($elem)
$elem->isa("PPI::Token::Word") $count = $open_func{$elem} Perl::Critic::Utils::is_function_call($elem)
Truth table0%0/4
A and B and C
A= $elem->isa("PPI::Token::Word")B= $count = $open_func{$elem}C= Perl::Critic::Utils::is_function_call($elem)
ABCresult
0XX0
10X0
1100
1111
440 && ($count = $open_func{$elem})
441 && Perl::Critic::Utils::is_function_call($elem)) {
442 0 return 0;
443 }
444 0 $my = $elem->snext_sibling;
445  
446 # with parens is
447 # PPI::Token::Word 'open'
448 # PPI::Structure::List ( ... )
449 # PPI::Statement::Variable
450 # PPI::Token::Word 'my'
451 # PPI::Token::Symbol '$fh'
452 # PPI::Token::Operator ','
453 #
454 0 ▶ if ($my->isa('PPI::Structure::List')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($my->isa("PPI::Structure::List")) 0 0 0
455 0 ▶ $my = $my->schild(0) || return 0;
Condition0%0/2
$my->schild(0) || (return 0)
l!l
00
MC/DC0%0/1
$my->schild(0) || (return 0)
$my->schild(0)
Truth table0%0/2
A
A= $my->schild(0)
Aresult
11
00
456 }
457 0 ▶ if ($my->isa('PPI::Statement::Variable')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($my->isa("PPI::Statement::Variable")) 0 0 0
458 0 ▶ $my = $my->schild(0) || return 0;
Condition0%0/2
$my->schild(0) || (return 0)
l!l
00
MC/DC0%0/1
$my->schild(0) || (return 0)
$my->schild(0)
Truth table0%0/2
A
A= $my->schild(0)
Aresult
11
00
459 }
460  
461 0 foreach (1 .. $count) {
462 ### my: "$my"
463 0 ▶ if (_is_uninitialized_my($my)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_uninitialized_my($my)) 0 0 0
464 0 return 1;
465 }
466 0 ▶ $my = _skip_to_next_arg($my) || last;
Condition0%0/2
_skip_to_next_arg($my) || (last)
l!l
00
MC/DC0%0/1
_skip_to_next_arg($my) || (last)
_skip_to_next_arg($my)
Truth table0%0/2
A
A= _skip_to_next_arg($my)
Aresult
11
00
467 }
468 0 return 0;
469 0 });
470 }
471  
472 0 ▶sub _is_uninitialized_my {
Subroutine _is_uninitialized_my: not called CC=8 SCAR=42.8
473 0 my ($my) = @_;
474 0 my ($fh, $after);
475 0 ▶ return ($my->isa('PPI::Token::Word')
Condition0%0/21
$my->isa('PPI::Token::Word') && $my eq 'my' && ($fh = $my->snext_sibling) && $fh->isa('PPI::Token::Symbol') && $fh->symbol_type eq '$' && !(($after = $fh->snext_sibling) && $after->isa('PPI::Token::Operator') && $after eq '=')
!ll&&!rl&&r
000
$my->isa("PPI::Token::Word") and $my eq "my" and $fh = $my->snext_sibling and $fh->isa("PPI::Token::Symbol") and $fh->symbol_type eq "\$"
!ll&&!rl&&r
000
$my->isa("PPI::Token::Word") and $my eq "my" and $fh = $my->snext_sibling and $fh->isa("PPI::Token::Symbol")
!ll&&!rl&&r
000
$my->isa("PPI::Token::Word") and $my eq "my" and $fh = $my->snext_sibling
!ll&&!rl&&r
000
$my->isa("PPI::Token::Word") and $my eq "my"
!ll&&!rl&&r
000
($after = $fh->snext_sibling) && $after->isa('PPI::Token::Operator') && $after eq '='
!ll&&!rl&&r
000
$after = $fh->snext_sibling and $after->isa("PPI::Token::Operator")
!ll&&!rl&&r
000
MC/DC0%0/8
$my->isa('PPI::Token::Word') && $my eq 'my' && ($fh = $my->snext_sibling) && $fh->isa('PPI::Token::Symbol') && $fh->symbol_type eq '$' && !(($after = $fh->snext_sibling) && $after->isa('PPI::Token::Operator') && $after eq '=')
$my->isa("PPI::Token::Word") $my eq "my" $fh = $my->snext_sibling $fh->isa("PPI::Token::Symbol") $fh->symbol_type eq "\$" $after = $fh->snext_sibling $after->isa("PPI::Token::Operator") $after eq '='
Truth table0%0/9
A and B and C and D and E && not(F and G && H)
A= $my->isa("PPI::Token::Word")B= $my eq "my"C= $fh = $my->snext_siblingD= $fh->isa("PPI::Token::Symbol")E= $fh->symbol_type eq "\$"F= $after = $fh->snext_siblingG= $after->isa("PPI::Token::Operator")H= $after eq '='
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
110XXXXX0
1110XXXX0
11110XXX0
111111110
111110XX1
1111110X1
111111101
476 && $my eq 'my'
477 && ($fh = $my->snext_sibling)
478 && $fh->isa('PPI::Token::Symbol')
479 && $fh->symbol_type eq '$'
480 && ! (($after = $fh->snext_sibling)
481 && $after->isa('PPI::Token::Operator')
482 && $after eq '='));
483 }
484  
485 # FIXME: is this enough for prototyped funcalls in the args?
486 0 ▶sub _skip_to_next_arg {
Subroutine _skip_to_next_arg: not called CC=4 SCAR=30.0
487 0 my ($elem) = @_;
488 0 for (;;) {
489 0 ▶ my $next = $elem->snext_sibling || return undef;
Condition0%0/2
$elem->snext_sibling || (return undef)
l!l
00
MC/DC0%0/1
$elem->snext_sibling || (return undef)
$elem->snext_sibling
Truth table0%0/2
A
A= $elem->snext_sibling
Aresult
11
00
490 0 ▶ if ($elem->isa('PPI::Token::Operator')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Operator") and $Perl::Critic::Pulp::Utils::COMMA{$elem}) 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Operator") and $Perl::Critic::Pulp::Utils::COMMA{$elem}
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Operator") and $Perl::Critic::Pulp::Utils::COMMA{$elem}
$elem->isa("PPI::Token::Operator") $Perl::Critic::Pulp::Utils::COMMA{$elem}
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Operator")B= $Perl::Critic::Pulp::Utils::COMMA{$elem}
ABresult
0X0
100
111
491 && $Perl::Critic::Pulp::Utils::COMMA{$elem}) {
492 0 return $next;
493 }
494 0 $elem = $next;
495 }
496 }
497  
498 # $obj->$method; omit parens new in 5.6.0
499 # previously required parens like $obj->$method();
500 #
501 0 ▶sub Perl::MinimumVersion::_Pulp__var_method_without_parens {
Subroutine _Pulp__var_method_without_parens: not called CC=1 SCAR=6.9
502 0 my ($pmv) = @_;
503 ### _Pulp__var_method_without_parens() ...
504 $pmv->Document->find_first
505 0 ▶ (sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
506 0 my ($document, $elem) = @_;
507 0 my $next;
508 0 ▶ if ($elem->isa('PPI::Token::Symbol')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Symbol') and $elem->symbol_type eq '$' and Perl::Critic::Utils::is_method_call($elem) and not +($next = $elem->snext_sibling) && $next->isa('PPI::Structure::List')) { } 0 0 0
Condition0%0/12
$elem->isa("PPI::Token::Symbol") and $elem->symbol_type eq "\$" and Perl::Critic::Utils::is_method_call($elem) and not +($next = $elem->snext_sibling) && $next->isa("PPI::Structure::List")
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Symbol") and $elem->symbol_type eq "\$" and Perl::Critic::Utils::is_method_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Symbol") and $elem->symbol_type eq "\$"
!ll&&!rl&&r
000
($next = $elem->snext_sibling) && $next->isa('PPI::Structure::List')
!ll&&!rl&&r
000
MC/DC0%0/5
$elem->isa("PPI::Token::Symbol") and $elem->symbol_type eq "\$" and Perl::Critic::Utils::is_method_call($elem) and not +($next = $elem->snext_sibling) && $next->isa("PPI::Structure::List")
$elem->isa("PPI::Token::Symbol") $elem->symbol_type eq "\$" Perl::Critic::Utils::is_method_call($elem) ($next = $elem->snext_sibling) $next->isa('PPI::Structure::List')
Truth table0%0/6
A and B and C and not(D && E)
A= $elem->isa("PPI::Token::Symbol")B= $elem->symbol_type eq "\$"C= Perl::Critic::Utils::is_method_call($elem)D= ($next = $elem->snext_sibling)E= $next->isa('PPI::Structure::List')
ABCDEresult
0XXXX0
10XXX0
110XX0
111110
1110X1
111101
509 && $elem->symbol_type eq '$'
510 && Perl::Critic::Utils::is_method_call($elem)
511 # must be followed by "()" for earlier perl, so if not then it
512 # means 5.6.0 required
513 && ! (($next = $elem->snext_sibling)
514 && $next->isa('PPI::Structure::List'))) {
515 0 return 1;
516 } else {
517 0 return 0;
518 }
519 0 });
520 }
521  
522 #-----------------------------------------------------------------------------
523 # Foo::Bar:: bareword new in 5.005
524 # generally a compile-time syntax error in 5.004
525 #
526 0 ▶sub Perl::MinimumVersion::_Pulp__bareword_double_colon {
Subroutine _Pulp__bareword_double_colon: not called CC=1 SCAR=6.9
527 0 my ($pmv) = @_;
528 ### _Pulp__bareword_double_colon() check
529 $pmv->Document->find_first
530 0 ▶ (sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
531 0 my ($document, $elem) = @_;
532 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem =~ /::$/) { } 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Word") and $elem =~ /::$/
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Word") and $elem =~ /::$/
$elem->isa("PPI::Token::Word") $elem =~ /::$/
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Word")B= $elem =~ /::$/
ABresult
0X0
100
111
533 && $elem =~ /::$/) {
534 0 return 1;
535 } else {
536 0 return 0;
537 }
538 0 });
539 }
540  
541 # my ($x, undef, $y), undef in a my() list new in 5.005
542 # usually something like my (undef, $x) = @values
543 #
544 0 ▶sub Perl::MinimumVersion::_Pulp__my_list_with_undef {
Subroutine _Pulp__my_list_with_undef: not called CC=1 SCAR=6.9
545 0 my ($pmv) = @_;
546 ### _Pulp__my_list_with_undef() check
547 $pmv->Document->find_first
548 0 ▶ (sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
549 0 my ($document, $elem) = @_;
550 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq 'my' and _list_contains_undef($elem->snext_sibling)) { } 0 0 0
Condition0%0/6
$elem->isa("PPI::Token::Word") and $elem eq "my" and _list_contains_undef($elem->snext_sibling)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "my"
!ll&&!rl&&r
000
MC/DC0%0/3
$elem->isa("PPI::Token::Word") and $elem eq "my" and _list_contains_undef($elem->snext_sibling)
$elem->isa("PPI::Token::Word") $elem eq "my" _list_contains_undef($elem->snext_sibling)
Truth table0%0/4
A and B and C
A= $elem->isa("PPI::Token::Word")B= $elem eq "my"C= _list_contains_undef($elem->snext_sibling)
ABCresult
0XX0
10X0
1100
1111
551 && $elem eq 'my'
552 && _list_contains_undef ($elem->snext_sibling)) {
553 0 return 1;
554 } else {
555 0 return 0;
556 }
557 0 });
558 }
559  
560 # $elem is a PPI::Element or false
561 # return true if it's a list and there's an 'undef' element in the list
562 #
563 # PPI::Structure::List ( ... )
564 # PPI::Statement::Expression
565 # PPI::Token::Symbol '$x'
566 # PPI::Token::Operator ','
567 # PPI::Token::Word 'undef'
568 # PPI::Token::Operator ','
569 # PPI::Token::Symbol '$y'
570 #
571 # Or for multi-parens: my ((undef)) with PPI::Statement in the middle
572 #
573 # PPI::Structure::List ( ... )
574 # PPI::Statement
575 # PPI::Structure::List ( ... )
576 # PPI::Statement::Expression
577 # PPI::Token::Word 'undef'
578 #
579 0 ▶sub _list_contains_undef {
Subroutine _list_contains_undef: not called CC=9 SCAR=45.0
580 0 my ($elem) = @_;
581 ### _list_contains_undef: "$elem"
582 0 ▶ $elem or return;
Branch: 1 branch
BranchTrueFalseTotal
$elem or return 0 0 0
583 0 ▶ $elem->isa('PPI::Structure::List') or return;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Structure::List") or return 0 0 0
584 0 my @search = ($elem);
585 0 ▶ while (@search) {
Branch: 1 branch
BranchTrueFalseTotal
if (@search) 0 0 0
586 0 $elem = pop @search;
587 ### elem: "$elem"
588 0 ▶ if ($elem->isa('PPI::Structure::List')
Branch: 2 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Structure::List') or $elem->isa('PPI::Statement::Expression') or $elem->isa('PPI::Statement')) { } 0 0 0
elsif ($elem->isa('PPI::Token::Word') and $elem eq 'undef') { } 0 0 0
Condition0%0/6
$elem->isa("PPI::Structure::List") or $elem->isa("PPI::Statement::Expression") or $elem->isa("PPI::Statement")
l!l&&r!l&&!r
000
$elem->isa("PPI::Structure::List") or $elem->isa("PPI::Statement::Expression")
l!l&&r!l&&!r
000
MC/DC0%0/3
$elem->isa("PPI::Structure::List") or $elem->isa("PPI::Statement::Expression") or $elem->isa("PPI::Statement")
$elem->isa("PPI::Structure::List") $elem->isa("PPI::Statement::Expression") $elem->isa("PPI::Statement")
Truth table0%0/4
A or B or C
A= $elem->isa("PPI::Structure::List")B= $elem->isa("PPI::Statement::Expression")C= $elem->isa("PPI::Statement")
ABCresult
1XX1
01X1
0011
0000
589 || $elem->isa('PPI::Statement::Expression')
590 || $elem->isa('PPI::Statement')) {
591 0 push @search, $elem->schildren;
592 ▶ } elsif ($elem->isa('PPI::Token::Word')
Condition0%0/3
$elem->isa("PPI::Token::Word") and $elem eq "undef"
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Word") and $elem eq "undef"
$elem->isa("PPI::Token::Word") $elem eq "undef"
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Word")B= $elem eq "undef"
ABresult
0X0
100
111
593 && $elem eq 'undef') {
594 0 return 1;
595 }
596 }
597 }
598  
599  
600 #-----------------------------------------------------------------------------
601 # pack() / unpack()
602 #
603 # Nothing new in 5.12, nothing new in 5.14.
604  
605 0 ▶sub Perl::MinimumVersion::_Pulp__pack_format_5004 {
Subroutine _Pulp__pack_format_5004: not called CC=1 SCAR=6.9
606 0 my ($pmv) = @_;
607 # w - BER integer
608 0 return _pack_format ($pmv, qr/w/);
609 }
610 0 ▶sub Perl::MinimumVersion::_Pulp__pack_format_5006 {
Subroutine _Pulp__pack_format_5006: not called CC=1 SCAR=6.9
611 0 my ($pmv) = @_;
612 # Z - asciz
613 # q - signed quad
614 # Q - unsigned quad
615 # ! - native size
616 # / - counted string
617 # # - comment
618 0 return _pack_format ($pmv, qr{[ZqQ!/#]});
619 }
620 0 ▶sub Perl::MinimumVersion::_Pulp__pack_format_5008 {
Subroutine _Pulp__pack_format_5008: not called CC=1 SCAR=6.9
621 0 my ($pmv) = @_;
622 # F - NV
623 # D - long double
624 # j - IV
625 # J - UV
626 # ( - group
627 # [ - in a repeat count like "L[20]"
628 0 return _pack_format ($pmv, qr/[FDjJ([]/);
629 }
630 0 ▶sub Perl::MinimumVersion::_Pulp__pack_format_5010 {
Subroutine _Pulp__pack_format_5010: not called CC=1 SCAR=6.9
631 0 my ($pmv) = @_;
632 # < - little endian
633 # > - big endian
634 0 return _pack_format ($pmv, qr/[<>]/);
635 }
636 # Think nothing new in 5012 ...
637  
638 40 my %pack_func = (pack => 1, unpack => 1);
639 0 ▶sub _pack_format {
Subroutine _pack_format: not called CC=1 SCAR=6.9
640 0 my ($pmv, $regexp) = @_;
641 0 require Perl::Critic::Policy::Miscellanea::TextDomainPlaceholders;
642 $pmv->Document->find_first
643 0 ▶ (sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
644 0 my ($document, $elem) = @_;
645  
646 0 ▶ $elem->isa ('PPI::Token::Word') || return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Word") or return 0 0 0 0
647 0 ▶ $pack_func{$elem->content} || return 0;
Branch: 1 branch
BranchTrueFalseTotal
$pack_func{$elem->content} or return 0 0 0 0
648 0 ▶ Perl::Critic::Utils::is_function_call($elem) || return 0;
Branch: 1 branch
BranchTrueFalseTotal
Perl::Critic::Utils::is_function_call($elem) or return 0 0 0 0
649  
650 0 my @args = parse_arg_list ($elem);
651 0 my $format_arg = $args[0];
652 ### format: @$format_arg
653  
654 0 my ($str, $any_vars) = Perl::Critic::Policy::Miscellanea::TextDomainPlaceholders::_arg_string ($format_arg, $document);
655 ### $str
656 ### $any_vars
657  
658 0 ▶ if ($any_vars) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($any_vars) 0 0 0
659 0 return ($str =~ $regexp);
660 0 });
661 }
662  
663 # 5.004 new __PACKAGE__
664 #
665 0 ▶sub Perl::MinimumVersion::_Pulp__special_literal__PACKAGE__ {
Subroutine _Pulp__special_literal__PACKAGE__: not called CC=1 SCAR=6.9
666 0 my ($pmv) = @_;
667 ### _Pulp__special_literal__PACKAGE__
668 $pmv->Document->find_first
669 0 ▶ (sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
670 0 my ($document, $elem) = @_;
671 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq '__PACKAGE__' and not Perl::Critic::Utils::is_hash_key($elem)) { } 0 0 0
Condition0%0/6
$elem->isa("PPI::Token::Word") and $elem eq "__PACKAGE__" and not Perl::Critic::Utils::is_hash_key($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "__PACKAGE__"
!ll&&!rl&&r
000
MC/DC0%0/3
$elem->isa("PPI::Token::Word") and $elem eq "__PACKAGE__" and not Perl::Critic::Utils::is_hash_key($elem)
$elem->isa("PPI::Token::Word") $elem eq "__PACKAGE__" not Perl::Critic::Utils::is_hash_key($elem)
Truth table0%0/4
A and B and not(C)
A= $elem->isa("PPI::Token::Word")B= $elem eq "__PACKAGE__"C= not Perl::Critic::Utils::is_hash_key($elem)
ABCresult
0XX0
10X0
1100
1111
672 && $elem eq '__PACKAGE__'
673 && ! Perl::Critic::Utils::is_hash_key($elem)) {
674 0 return 1;
675 } else {
676 0 return 0;
677 }
678 0 });
679 }
680  
681 # 5.004 new "use VERSION"
682 #
683 # "use MODULE VERSION" is not as easy, fairly sure it depends whether the
684 # target module uses Exporter.pm or not since the VERSION part is passed to
685 # import() and Exporter.pm checks it.
686 #
687 0 ▶sub Perl::MinimumVersion::_Pulp__use_version_number {
Subroutine _Pulp__use_version_number: not called CC=1 SCAR=6.9
688 0 my ($pmv) = @_;
689 ### _Pulp__use_version_number
690 $pmv->Document->find_first
691 0 ▶ (sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
692 0 my ($document, $elem) = @_;
693 0 ▶ $elem->isa('PPI::Statement::Include') or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Statement::Include") or return 0 0 0 0
694 0 ▶ $elem->type eq 'use' or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->type eq "use" or return 0 0 0 0
695 0 ▶ if ($elem->version ne '') { # empty string '' for not a "use VERSION"
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->version ne '') { } 0 0 0
696 0 return 1;
697 } else {
698 0 return 0;
699 }
700 0 });
701 }
702  
703 # 5.004 new "foreach my $i" lexical loop variable
704 #
705 0 ▶sub Perl::MinimumVersion::_Pulp__for_loop_variable_using_my {
Subroutine _Pulp__for_loop_variable_using_my: not called CC=1 SCAR=6.9
706 0 my ($pmv) = @_;
707 ### _Pulp__for_loop_variable_using_my
708 $pmv->Document->find_first
709 0 ▶ (sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
710 0 my ($document, $elem) = @_;
711 0 ▶ $elem->isa('PPI::Statement::Compound') or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Statement::Compound") or return 0 0 0 0
712 0 ▶ $elem->type eq 'foreach' or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->type eq "foreach" or return 0 0 0 0
713 0 ▶ my $second = $elem->schild(1) || return 0;
Condition0%0/2
$elem->schild(1) || (return 0)
l!l
00
MC/DC0%0/1
$elem->schild(1) || (return 0)
$elem->schild(1)
Truth table0%0/2
A
A= $elem->schild(1)
Aresult
11
00
714 0 ▶ $second->isa('PPI::Token::Word') or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$second->isa("PPI::Token::Word") or return 0 0 0 0
715 0 ▶ if ($second eq 'my') {
Branch: 1 branch
BranchTrueFalseTotal
if ($second eq 'my') { } 0 0 0
716 0 return 1;
717 } else {
718 0 return 0;
719 }
720 0 });
721 }
722  
723 # 5.004 new "$foo->(PARAMS)" coderef call
724 #
725 0 ▶sub Perl::MinimumVersion::_Pulp__arrow_coderef_call {
Subroutine _Pulp__arrow_coderef_call: not called CC=1 SCAR=6.9
726 0 my ($pmv) = @_;
727 ### _Pulp__arrow_coderef_call
728 $pmv->Document->find_first
729 0 ▶ (sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
730 0 my ($document, $elem) = @_;
731 0 ▶ $elem->isa('PPI::Token::Operator') or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Operator") or return 0 0 0 0
732 ### operator: "$elem"
733 0 ▶ $elem eq '->' or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem eq "->" or return 0 0 0 0
734 0 ▶ $elem = $elem->snext_sibling || return 0;
Condition0%0/2
$elem->snext_sibling || (return 0)
l!l
00
MC/DC0%0/1
$elem->snext_sibling || (return 0)
$elem->snext_sibling
Truth table0%0/2
A
A= $elem->snext_sibling
Aresult
11
00
735 ### next: "$elem"
736 0 ▶ if ($elem->isa('PPI::Structure::List')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Structure::List')) { } 0 0 0
737 0 return 1;
738 } else {
739 0 return 0;
740 }
741 0 });
742 }
743  
744 # 5.004 new sysseek() function
745 #
746 # Crib note: the prototype() function is newly documented in 5.004 but
747 # existed earlier, or something. Might have returned a trailing "\0" in
748 # 5.003.
749 #
750 0 ▶sub Perl::MinimumVersion::_Pulp__sysseek_builtin {
Subroutine _Pulp__sysseek_builtin: not called CC=1 SCAR=6.9
751 0 my ($pmv) = @_;
752 ### _Pulp__sysseek_builtin
753 $pmv->Document->find_first
754 0 ▶ (sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
755 0 my ($document, $elem) = @_;
756 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq 'sysseek' || $elem eq 'CORE::sysseek' and Perl::Critic::Utils::is_function_call($elem)) { } 0 0 0
Condition0%0/9
$elem->isa("PPI::Token::Word") and $elem eq "sysseek" || $elem eq "CORE::sysseek" and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "sysseek" || $elem eq "CORE::sysseek"
!ll&&!rl&&r
000
$elem eq "sysseek" or $elem eq "CORE::sysseek"
l!l&&r!l&&!r
000
MC/DC0%0/4
$elem->isa("PPI::Token::Word") and $elem eq "sysseek" || $elem eq "CORE::sysseek" and Perl::Critic::Utils::is_function_call($elem)
$elem->isa("PPI::Token::Word") $elem eq "sysseek" $elem eq "CORE::sysseek" Perl::Critic::Utils::is_function_call($elem)
Truth table0%0/6
A and B or C and D
A= $elem->isa("PPI::Token::Word")B= $elem eq "sysseek"C= $elem eq "CORE::sysseek"D= Perl::Critic::Utils::is_function_call($elem)
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
757 && ($elem eq 'sysseek' || $elem eq 'CORE::sysseek')
758 && Perl::Critic::Utils::is_function_call ($elem)) {
759 0 return 1;
760 } else {
761 0 return 0;
762 }
763 0 });
764 }
765  
766  
767 #---------------------------------------------------------------------------
768 # UNIVERSAL.pm methods
769 #
770 {
771 40 my $methods = { VERSION => 1,
772 isa => 1,
773 can => 1 };
774 0 ▶ sub Perl::MinimumVersion::_Pulp__UNIVERSAL_methods_5004 {
Subroutine _Pulp__UNIVERSAL_methods_5004: not called CC=1 SCAR=6.9
775 0 my ($pmv) = @_;
776 ### _Pulp__UNIVERSAL_methods_5004() ...
777 0 return _any_method($pmv,$methods);
778 }
779 }
780 {
781 40 my $methods = { DOES => 1 };
782 0 ▶ sub Perl::MinimumVersion::_Pulp__UNIVERSAL_methods_5010 {
Subroutine _Pulp__UNIVERSAL_methods_5010: not called CC=1 SCAR=6.9
783 0 my ($pmv) = @_;
784 ### _Pulp__UNIVERSAL_methods_5010() ...
785 0 return _any_method($pmv,$methods);
786 }
787 }
788 40 ▶sub _any_method {
Subroutine _any_method: not called CC=1 SCAR=6.0
789 0 my ($pmv, $hash) = @_;
790 $pmv->Document->find_first
791 0 ▶ (sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
792 0 my ($document, $elem) = @_;
793 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $hash->{$elem} and Perl::Critic::Utils::is_method_call($elem)) { } 0 0 0
Condition0%0/6
$elem->isa("PPI::Token::Word") and $hash->{$elem} and Perl::Critic::Utils::is_method_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $hash->{$elem}
!ll&&!rl&&r
000
MC/DC0%0/3
$elem->isa("PPI::Token::Word") and $hash->{$elem} and Perl::Critic::Utils::is_method_call($elem)
$elem->isa("PPI::Token::Word") $hash->{$elem} Perl::Critic::Utils::is_method_call($elem)
Truth table0%0/4
A and B and C
A= $elem->isa("PPI::Token::Word")B= $hash->{$elem}C= Perl::Critic::Utils::is_method_call($elem)
ABCresult
0XX0
10X0
1100
1111
794 && $hash->{$elem}
795 && Perl::Critic::Utils::is_method_call ($elem)) {
796 0 return 1;
797 } else {
798 0 return 0;
799 }
800 0 });
801 }
802  
803  
804 #------------------------------------------------------------------------------
805 # keys @foo, values @foo, each @foo new in 5.12.0
806 #
807 0 ▶sub Perl::MinimumVersion::_Pulp__keys_of_array {
Subroutine _Pulp__keys_of_array: not called CC=1 SCAR=6.9
808 0 my ($pmv) = @_;
809 0 return _keys_etc_of_array ($pmv, 'keys');
810 }
811 0 ▶sub Perl::MinimumVersion::_Pulp__values_of_array {
Subroutine _Pulp__values_of_array: not called CC=1 SCAR=6.9
812 0 my ($pmv) = @_;
813 0 return _keys_etc_of_array ($pmv, 'values');
814 }
815 0 ▶sub Perl::MinimumVersion::_Pulp__each_of_array {
Subroutine _Pulp__each_of_array: not called CC=1 SCAR=6.9
816 0 my ($pmv) = @_;
817 0 return _keys_etc_of_array ($pmv, 'each');
818 }
819 0 ▶sub _keys_etc_of_array {
Subroutine _keys_etc_of_array: not called CC=1 SCAR=6.9
820 0 my ($pmv, $which) = @_;
821 ### _keys_etc_of_array() ...
822 $pmv->Document->find_first
823 0 ▶ (sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
824 0 my ($document, $elem) = @_;
825 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Word') and $elem eq $which and Perl::Critic::Utils::is_function_call($elem) and _arg_is_array($elem->snext_sibling)) { } 0 0 0
Condition0%0/9
$elem->isa("PPI::Token::Word") and $elem eq $which and Perl::Critic::Utils::is_function_call($elem) and _arg_is_array($elem->snext_sibling)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq $which and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq $which
!ll&&!rl&&r
000
MC/DC0%0/4
$elem->isa("PPI::Token::Word") and $elem eq $which and Perl::Critic::Utils::is_function_call($elem) and _arg_is_array($elem->snext_sibling)
$elem->isa("PPI::Token::Word") $elem eq $which Perl::Critic::Utils::is_function_call($elem) _arg_is_array($elem->snext_sibling)
Truth table0%0/5
A and B and C and D
A= $elem->isa("PPI::Token::Word")B= $elem eq $whichC= Perl::Critic::Utils::is_function_call($elem)D= _arg_is_array($elem->snext_sibling)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
826 && $elem eq $which
827 && Perl::Critic::Utils::is_function_call($elem)
828 && _arg_is_array($elem->snext_sibling)) {
829 0 return 1;
830 } else {
831 0 return 0;
832 }
833 0 });
834 }
835 0 ▶sub _arg_is_array {
Subroutine _arg_is_array: not called CC=6 SCAR=37.4
836 0 my ($elem) = @_;
837 ### _arg_is_array "$elem"
838  
839 0 ▶ $elem = _descend_through_lists($elem) || return 0;
Condition0%0/2
_descend_through_lists($elem) || (return 0)
l!l
00
MC/DC0%0/1
_descend_through_lists($elem) || (return 0)
_descend_through_lists($elem)
Truth table0%0/2
A
A= _descend_through_lists($elem)
Aresult
11
00
840  
841 0 ▶ if ($elem->isa('PPI::Token::Symbol')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\@") 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\@"
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Symbol") and $elem->raw_type eq "\@"
$elem->isa("PPI::Token::Symbol") $elem->raw_type eq "\@"
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Symbol")B= $elem->raw_type eq "\@"
ABresult
0X0
100
111
842 && $elem->raw_type eq '@') {
843 0 return 1;
844 }
845 0 ▶ if ($elem->isa('PPI::Token::Cast') && $elem eq '@') {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Cast") and $elem eq "\@") 0 0 0
Condition0%0/3
$elem->isa("PPI::Token::Cast") and $elem eq "\@"
!ll&&!rl&&r
000
MC/DC0%0/2
$elem->isa("PPI::Token::Cast") and $elem eq "\@"
$elem->isa("PPI::Token::Cast") $elem eq "\@"
Truth table0%0/3
A and B
A= $elem->isa("PPI::Token::Cast")B= $elem eq "\@"
ABresult
0X0
100
111
846 0 return 1;
847 }
848 0 return 0;
849 }
850  
851  
852 #------------------------------------------------------------------------------
853 # eval '#line ...' with the #line the very first thing,
854 # the #line doesn't take effect until 5.008,
855 # in 5.006 need a blank line or something first
856  
857 {
858 40 my $initial_line_re = qr/^#[ \t]*line/;
859  
860 0 ▶ sub Perl::MinimumVersion::_Pulp__eval_line_directive_first_thing {
Subroutine _Pulp__eval_line_directive_first_thing: not called CC=1 SCAR=6.9
861 0 my ($pmv) = @_;
862 ### _Pulp__eval_line_directive_first_thing() ...
863 $pmv->Document->find_first
864 0 ▶ (sub {
Subroutine __ANON__: not called CC=10 SCAR=47.0
865 0 my ($document, $elem) = @_;
866 0 ▶ if ($elem->isa('PPI::Token::Word')
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Word") and $elem eq "eval" and Perl::Critic::Utils::is_function_call($elem) and $elem = $elem->snext_sibling and $elem = _descend_through_lists($elem)) 0 0 0
Condition0%0/12
$elem->isa("PPI::Token::Word") and $elem eq "eval" and Perl::Critic::Utils::is_function_call($elem) and $elem = $elem->snext_sibling and $elem = _descend_through_lists($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "eval" and Perl::Critic::Utils::is_function_call($elem) and $elem = $elem->snext_sibling
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "eval" and Perl::Critic::Utils::is_function_call($elem)
!ll&&!rl&&r
000
$elem->isa("PPI::Token::Word") and $elem eq "eval"
!ll&&!rl&&r
000
MC/DC0%0/5
$elem->isa("PPI::Token::Word") and $elem eq "eval" and Perl::Critic::Utils::is_function_call($elem) and $elem = $elem->snext_sibling and $elem = _descend_through_lists($elem)
$elem->isa("PPI::Token::Word") $elem eq "eval" Perl::Critic::Utils::is_function_call($elem) $elem = $elem->snext_sibling $elem = _descend_through_lists($elem)
Truth table0%0/6
A and B and C and D and E
A= $elem->isa("PPI::Token::Word")B= $elem eq "eval"C= Perl::Critic::Utils::is_function_call($elem)D= $elem = $elem->snext_siblingE= $elem = _descend_through_lists($elem)
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
867 && $elem eq 'eval'
868 && Perl::Critic::Utils::is_function_call($elem)
869 && ($elem = $elem->snext_sibling)
870 && ($elem = _descend_through_lists($elem))) {
871 ### eval of: "$elem"
872  
873 0 ▶ if ($elem->isa('PPI::Token::Quote')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Quote')) { } 0 0 0
elsif ($elem->isa('PPI::Token::HereDoc')) { } 0 0 0
874 0 ▶ if ($elem->string =~ $initial_line_re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->string =~ /$initial_line_re/) 0 0 0
875 0 return 1;
876 }
877 } elsif ($elem->isa('PPI::Token::HereDoc')) {
878 0 my ($str) = $elem->heredoc; # first line
879 0 ▶ if ($str =~ $initial_line_re) {
Branch: 1 branch
BranchTrueFalseTotal
if ($str =~ /$initial_line_re/) 0 0 0
880 0 return 1;
881 }
882 }
883 }
884 0 return 0;
885 0 });
886 }
887 }
888  
889  
890 #---------------------------------------------------------------------------
891 # generic
892  
893 # if $elem is a symbol or a List of a symbol then return that symbol elem,
894 # otherwise return an empty list
895 #
896 40 ▶sub _symbol_or_list_symbol {
Subroutine _symbol_or_list_symbol: not called CC=6 SCAR=35.9
897 0 my ($elem) = @_;
898 0 ▶ if ($elem->isa('PPI::Structure::List')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Structure::List")) 0 0 0
899 0 ▶ $elem = $elem->schild(0) || return;
Condition0%0/2
$elem->schild(0) || (return)
l!l
00
MC/DC0%0/1
$elem->schild(0) || (return)
$elem->schild(0)
Truth table0%0/2
A
A= $elem->schild(0)
Aresult
11
00
900 0 ▶ $elem->isa('PPI::Statement::Expression') || return;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Statement::Expression") or return 0 0 0
901 0 ▶ $elem = $elem->schild(0) || return;
Condition0%0/2
$elem->schild(0) || (return)
l!l
00
MC/DC0%0/1
$elem->schild(0) || (return)
$elem->schild(0)
Truth table0%0/2
A
A= $elem->schild(0)
Aresult
11
00
902 }
903 0 ▶ $elem->isa('PPI::Token::Symbol') || return;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Symbol") or return 0 0 0
904 0 return $elem;
905 }
906  
907  
908 #---------------------------------------------------------------------------
909  
910 40 1;
911 __END__
↑ Summary Policy/ValuesAndExpressions/ProhibitUnknownBackslash.pm »