Policy/Community/DeprecatedFeatures.pm

filter: Statementstmt 97.3% 111 / 114 Branchbran 97.3% 111 / 114 Conditioncond 83.9% 194 / 231 MC/DCmcdc 64.5% 71 / 110 Subroutinesub 92.8% 13 / 14 Podpod 80.0% 4 / 5 totaltotal 85.7% 504 / 588 CC 137 SCAR 48.4
CC
137
Cov
91%
violates
146.0
_violates_interpolated
6.0
__ANON__
3.0
CRAP 126.0
↑ Summary Policy/Community/MultidimensionalArrayEmulation.pm »
1 package Perl::Critic::Policy::Community::DeprecatedFeatures;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use List::Util 'any', 'none';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Perl::Critic::Utils qw(:severities :classification :ppi);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = 'v1.0.4';
11  
12 4 ▶sub supported_parameters { () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
13 75 ▶sub default_severity { $SEVERITY_HIGH }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
14 0 ▶sub default_themes { 'community' }
Subroutine default_themes: not called CC=1 SCAR=6.9
Pod documented
15 4 ▶sub applies_to { 'PPI::Element' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
16  
17 1 my %features = (
18 ':=' => 'Use of := as an empty attribute list is deprecated in perl v5.12.0, use = alone.',
19 '$[' => 'Use of $[ is deprecated in perl v5.12.0. See Array::Base and String::Base.',
20 '/\\C/' => 'Use of the \\C character class in regular expressions is deprecated in perl v5.20.0. To examine a string\'s UTF-8-encoded byte representation, encode it to UTF-8.',
21 '?PATTERN?' => 'Use of ? as a match regex delimiter without an initial m is deprecated in perl v5.14.0. Use m?PATTERN? instead.',
22 'autoderef' => 'Use of each/keys/pop/push/shift/splice/unshift/values on a reference is an experimental feature that is removed in perl v5.24.0. Dereference the array or hash to use these functions on it.',
23 'Bare here-doc' => 'Use of bare << to create a here-doc with an empty string terminator is deprecated in perl 5. Use a quoted empty string like <<\'\'.',
24 'chdir(\'\')' => 'Use of chdir(\'\') or chdir(undef) to chdir home is deprecated in perl v5.8.0. Use chdir() instead.',
25 'defined on array/hash' => 'Use of defined() on an array or hash is deprecated in perl v5.6.2. The array or hash can be tested directly to check for non-emptiness: if (@foo) { ... }',
26 'do SUBROUTINE(LIST)' => 'Use of do to call a subroutine is deprecated in perl 5.',
27 'NBSP in \\N{...}' => 'Use of the "no-break space" character in character names is deprecated in perl v5.22.0.',
28 'POSIX character function' => 'Several character matching functions in POSIX.pm are deprecated in perl v5.20.0: isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, and isxdigit. Regular expressions are a more portable and correct way to test character strings.',
29 'POSIX::tmpnam()' => 'The tmpnam() function from POSIX is deprecated in perl v5.22.0. Use File::Temp instead.',
30 'qw(...) as parentheses' => 'Use of qw(...) as parentheses is deprecated in perl v5.14.0. Wrap the list in literal parentheses when required, such as in a foreach loop.',
31 'require ::Foo::Bar' => 'Bareword require starting with a double colon is an error in perl v5.26.0.',
32 'UNIVERSAL->import()' => 'The method UNIVERSAL->import() (or passing import arguments to "use UNIVERSAL") is deprecated in perl v5.12.0.',
33 );
34  
35 1 my %posix_deprecated = map { ($_ => 1, "POSIX::$_" => 1) }
36 qw(isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit);
37  
38 1 my %autoderef_functions = map { ($_ => 1) }
39 qw(each keys pop push shift splice unshift values);
40  
41 75 ▶sub _violation {
Subroutine _violation: called CC=2 SCAR=7.0
42 75 my ($self, $feature, $elem) = @_;
43 75 my $desc = "$feature is deprecated";
44 75 ▶ my $expl = $features{$feature} // "$feature is deprecated or removed from recent versions of Perl.";
Condition50%1/2
$features{$feature} // "$feature is deprecated or removed from recent versions of Perl."
l!l
750
MC/DC0%0/1
$features{$feature} // "$feature is deprecated or removed from recent versions of Perl."
$features{$feature}
Truth table50%1/2
A
A= $features{$feature}
Aresult
11
00
45 75 return $self->violation($desc, $expl, $elem);
46 }
47  
48 1165 ▶sub violates {
Subroutine violates: called CC=129 SCAR=49.8
Pod documented
49 1165 my ($self, $elem) = @_;
50 1165 my $next;
51 my $prev;
52 1165 my $parent;
53 1165 my @args;
54 1165 my @violations;
55 1165 ▶ if ($elem->isa('PPI::Statement')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Statement')) { } 199 966 1165
elsif ($elem->isa('PPI::Token')) { } 907 59 966
56 199 ▶ if ($elem->isa('PPI::Statement::Include')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Statement::Include")) 13 186 199
57 # use UNIVERSAL ...;
58 13 ▶ if ($elem->type eq 'use' and defined $elem->module and $elem->module eq 'UNIVERSAL') {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->type eq "use" and defined $elem->module and $elem->module eq "UNIVERSAL") 3 10 13
Condition83%5/6
$elem->type eq "use" and defined $elem->module and $elem->module eq "UNIVERSAL"
!ll&&!rl&&r
553
$elem->type eq "use" and defined $elem->module
!ll&&!rl&&r
508
MC/DC66%2/3
$elem->type eq "use" and defined $elem->module and $elem->module eq "UNIVERSAL"
$elem->type eq "use" defined $elem->module $elem->module eq "UNIVERSAL"
Truth table75%3/4
A and B and C
A= $elem->type eq "use"B= defined $elem->moduleC= $elem->module eq "UNIVERSAL"
ABCresult
0XX0
10X0
1100
1111
59 3 my @args = $elem->arguments;
60 3 ▶ if (!@args or !$args[0]->isa('PPI::Structure::List') or $args[0]->schildren) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @args && $args[0]->isa("PPI::Structure::List") or $args[0]->schildren) 2 1 3
Condition83%5/6
not @args && $args[0]->isa("PPI::Structure::List") or $args[0]->schildren
l!l&&r!l&&!r
201
@args && $args[0]->isa('PPI::Structure::List')
!ll&&!rl&&r
111
MC/DC66%2/3
not @args && $args[0]->isa("PPI::Structure::List") or $args[0]->schildren
@args $args[0]->isa('PPI::Structure::List') $args[0]->schildren
Truth table75%3/4
not(A && B) or C
A= @argsB= $args[0]->isa('PPI::Structure::List')C= $args[0]->schildren
ABCresult
0XX1
10X1
1111
1100
61 2 push @violations, $self->_violation('UNIVERSAL->import()', $elem);
62 }
63 }
64 # require ::Foo::Bar
65 13 ▶ if (defined $elem->module and $elem->module =~ m/^::/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $elem->module and $elem->module =~ /^::/) 3 10 13
Condition66%2/3
defined $elem->module and $elem->module =~ /^::/
!ll&&!rl&&r
0103
MC/DC50%1/2
defined $elem->module and $elem->module =~ /^::/
defined $elem->module $elem->module =~ /^::/
Truth table66%2/3
A and B
A= defined $elem->moduleB= $elem->module =~ /^::/
ABresult
0X0
100
111
66 3 push @violations, $self->_violation('require ::Foo::Bar', $elem);
67 }
68 }
69 } elsif ($elem->isa('PPI::Token')) {
70 907 ▶ if ($elem->isa('PPI::Token::Symbol')) {
Branch: 7 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Symbol')) { } 92 815 907
elsif ($elem->isa('PPI::Token::Operator')) { } 49 766 815
elsif ($elem->isa('PPI::Token::Word')) { } 154 612 766
elsif ($elem->isa('PPI::Token::Regexp')) { } 8 604 612
elsif ($elem->isa('PPI::Token::HereDoc')) { } 3 601 604
elsif ($elem->isa('PPI::Token::QuoteLike')) { } 12 589 601
elsif ($elem->isa('PPI::Token::Quote')) { } 14 575 589
71 # $[
72 92 ▶ if ($elem eq '$[') {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem eq "\$[") 1 91 92
73 1 push @violations, $self->_violation('$[', $elem);
74 }
75 } elsif ($elem->isa('PPI::Token::Operator')) {
76 # :=
77 49 ▶ if ($elem eq ':' and $next = $elem->next_sibling and $next->isa('PPI::Token::Operator') and $next eq '=') {
Branch: 3 branches
BranchTrueFalseTotal
if ($elem eq ':' and $next = $elem->next_sibling and $next->isa('PPI::Token::Operator') and $next eq '=') { } 1 48 49
elsif ($elem eq '?' and $parent = $elem->parent and $parent->isa('PPI::Statement')) { } 6 42 48
elsif ($elem eq '<<' and !($next = $elem->snext_sibling) || $next->isa('PPI::Token::Operator') && $next ne '~' && $next ne '!' && $next ne '+' && $next ne '-' || $next->isa('PPI::Token::Structure') && $next ne '(' && $next ne '{' && $next ne '[') { } 4 76 80
Condition77%7/9
$elem eq ":" and $next = $elem->next_sibling and $next->isa("PPI::Token::Operator") and $next eq "="
!ll&&!rl&&r
4801
$elem eq ":" and $next = $elem->next_sibling and $next->isa("PPI::Token::Operator")
!ll&&!rl&&r
4351
$elem eq ":" and $next = $elem->next_sibling
!ll&&!rl&&r
4306
MC/DC50%2/4
$elem eq ":" and $next = $elem->next_sibling and $next->isa("PPI::Token::Operator") and $next eq "="
$elem eq ":" $next = $elem->next_sibling $next->isa("PPI::Token::Operator") $next eq "="
Truth table60%3/5
A and B and C and D
A= $elem eq ":"B= $next = $elem->next_siblingC= $next->isa("PPI::Token::Operator")D= $next eq "="
ABCDresult
0XXX0
10XX0
110X0
11100
11111
78 1 push @violations, $self->_violation(':=', $elem);
79 # ?PATTERN? - PPI parses this as multiple ? operators
80 ▶ } elsif ($elem eq '?' and $parent = $elem->parent and $parent->isa('PPI::Statement')) {
Condition66%4/6
$elem eq "?" and $parent = $elem->parent and $parent->isa("PPI::Statement")
!ll&&!rl&&r
4206
$elem eq "?" and $parent = $elem->parent
!ll&&!rl&&r
4206
MC/DC33%1/3
$elem eq "?" and $parent = $elem->parent and $parent->isa("PPI::Statement")
$elem eq "?" $parent = $elem->parent $parent->isa("PPI::Statement")
Truth table50%2/4
A and B and C
A= $elem eq "?"B= $parent = $elem->parentC= $parent->isa("PPI::Statement")
ABCresult
0XX0
10X0
1100
1111
81 6 $next = $elem->snext_sibling;
82 6 ▶ until (!$next or ($next->isa('PPI::Token::Operator') and $next eq '?')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (not $next or $next->isa("PPI::Token::Operator") and $next eq "?") 16 6 22
Condition100%6/6
not $next or $next->isa("PPI::Token::Operator") and $next eq "?"
l!l&&r!l&&!r
3316
$next->isa("PPI::Token::Operator") and $next eq "?"
!ll&&!rl&&r
1243
MC/DC100%3/3
not $next or $next->isa("PPI::Token::Operator") and $next eq "?"
not $next $next->isa("PPI::Token::Operator") $next eq "?"
Truth table100%4/4
not(A) or B and C
A= not $nextB= $next->isa("PPI::Token::Operator")C= $next eq "?"
ABCresult
1XX1
0111
00X0
0100
83 16 $next = $next->snext_sibling;
84 }
85 # If the statement has a : operator, this is probably a ternary operator.
86 # PPI also tends to detect the : as a loop label.
87 6 ▶ if ($next and none { ($_->isa('PPI::Token::Operator') and $_ eq ':') or $_->isa('PPI::Token::Label') } $parent->schildren) {
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 2 branches
BranchTrueFalseTotal
if ($next and &none(sub { $_->isa("PPI::Token::Operator") and $_ eq ":" or $_->isa("PPI::Token::Label"); } , $parent->schildren)) 1 5 6
$_->isa("PPI::Token::Operator") and $_ eq ":" or $_->isa("PPI::Token::Label") 2 16 18
Condition100%6/6
$next and &none(sub { $_->isa("PPI::Token::Operator") and $_ eq ":" or $_->isa("PPI::Token::Label"); } , $parent->schildren)
!ll&&!rl&&r
321
$_->isa("PPI::Token::Operator") and $_ eq ":"
!ll&&!rl&&r
972
MC/DC100%2/2
$next and &none(sub { $_->isa("PPI::Token::Operator") and $_ eq ":" or $_->isa("PPI::Token::Label"); } , $parent->schildren)
$next &none(sub { $_->isa("PPI::Token::Operator") and $_ eq ":" or $_->isa("PPI::Token::Label"); } , $parent->schildren)
MC/DC100%2/2
$_->isa("PPI::Token::Operator") and $_ eq ":"
$_->isa("PPI::Token::Operator") $_ eq ":"
Truth table100%3/3
A and B
A= $nextB= &none(sub { $_->isa("PPI::Token::Operator") and $_ eq ":" or $_->isa("PPI::Token::Label"); } , $parent->schildren)
ABresult
0X0
100
111
Truth table100%3/3
A and B
A= $_->isa("PPI::Token::Operator")B= $_ eq ":"
ABresult
0X0
100
111
88 1 push @violations, $self->_violation('?PATTERN?', $elem);
89 }
90 # Bare here-doc - differentiate this from the legitimate << operator
91 ▶ } elsif ($elem eq '<<' and (!($next = $elem->snext_sibling)
Condition80%24/30
$elem eq "<<" and !($next = $elem->snext_sibling) || $next->isa("PPI::Token::Operator") && $next ne "~" && $next ne "!" && $next ne "+" && $next ne "-" || $next->isa("PPI::Token::Structure") && $next ne "(" && $next ne "{" && $next ne "["
!ll&&!rl&&r
3624
not $next = $elem->snext_sibling or $next->isa("PPI::Token::Operator") and $next ne "~" and $next ne "!" and $next ne "+" and $next ne "-" or $next->isa("PPI::Token::Structure") and $next ne "(" and $next ne "{" and $next ne "["
l!l&&r!l&&!r
312
not $next = $elem->snext_sibling or $next->isa("PPI::Token::Operator") and $next ne "~" and $next ne "!" and $next ne "+" and $next ne "-"
l!l&&r!l&&!r
213
$next->isa("PPI::Token::Operator") and $next ne "~" and $next ne "!" and $next ne "+" and $next ne "-"
!ll&&!rl&&r
301
$next->isa("PPI::Token::Operator") and $next ne "~" and $next ne "!" and $next ne "+"
!ll&&!rl&&r
211
$next->isa("PPI::Token::Operator") and $next ne "~" and $next ne "!"
!ll&&!rl&&r
202
$next->isa("PPI::Token::Operator") and $next ne "~"
!ll&&!rl&&r
202
$next->isa("PPI::Token::Structure") and $next ne "(" and $next ne "{" and $next ne "["
!ll&&!rl&&r
201
$next->isa("PPI::Token::Structure") and $next ne "(" and $next ne "{"
!ll&&!rl&&r
201
$next->isa("PPI::Token::Structure") and $next ne "("
!ll&&!rl&&r
201
MC/DC45%5/11
$elem eq "<<" and !($next = $elem->snext_sibling) || $next->isa("PPI::Token::Operator") && $next ne "~" && $next ne "!" && $next ne "+" && $next ne "-" || $next->isa("PPI::Token::Structure") && $next ne "(" && $next ne "{" && $next ne "["
$elem eq "<<" not $next = $elem->snext_sibling $next->isa("PPI::Token::Operator") $next ne "~" $next ne "!" $next ne "+" $next ne "-" $next->isa("PPI::Token::Structure") $next ne "(" $next ne "{" $next ne "["
Truth table21%6/28
A and not(B) or C and D and E and F and G or H and I and J and K
A= $elem eq "<<"B= not $next = $elem->snext_siblingC= $next->isa("PPI::Token::Operator")D= $next ne "~"E= $next ne "!"F= $next ne "+"G= $next ne "-"H= $next->isa("PPI::Token::Structure")I= $next ne "("J= $next ne "{"K= $next ne "["
ABCDEFGHIJKresult
0XXXXXXXXXX0
100XXXX0XXX0
100XXXX10XX0
100XXXX110X0
100XXXX11100
1010XXX0XXX0
1010XXX10XX0
1010XXX110X0
1010XXX11100
10110XX0XXX0
10110XX10XX0
10110XX110X0
10110XX11100
101110X0XXX0
101110X10XX0
101110X110X0
101110X11100
10111100XXX0
101111010XX0
1011110110X0
101111011100
11XXXXXXXXX1
1011111XXXX1
100XXXX11111
1010XXX11111
10110XX11111
101110X11111
101111011111
92 or ($next->isa('PPI::Token::Operator') and $next ne '~' and $next ne '!' and $next ne '+' and $next ne '-')
93 or ($next->isa('PPI::Token::Structure') and $next ne '(' and $next ne '{' and $next ne '['))) {
94 4 push @violations, $self->_violation('Bare here-doc', $elem);
95 }
96 } elsif ($elem->isa('PPI::Token::Word')) {
97 # UNIVERSAL->import()
98 154 ▶ if ($elem eq 'UNIVERSAL'
Branch: 4 branches
BranchTrueFalseTotal
if ($elem eq 'UNIVERSAL' and $next = $elem->snext_sibling and $next->isa('PPI::Token::Operator') and $next eq '->' and $next = $next->snext_sibling and $next->isa('PPI::Token::Word') and $next eq 'import') { } 1 153 154
elsif ($elem eq 'for' || $elem eq 'foreach' and not $elem->sprevious_sibling) { } 2 151 153
elsif ($elem eq 'do' and $next = $elem->snext_sibling) { } 6 145 151
elsif (not +($prev = $elem->sprevious_sibling) && $prev->isa('PPI::Token::Operator') or $prev ne '->') { } 141 4 145
Condition77%14/18
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling and $next->isa("PPI::Token::Operator") and $next eq "->" and $next = $next->snext_sibling and $next->isa("PPI::Token::Word") and $next eq "import"
!ll&&!rl&&r
15211
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling and $next->isa("PPI::Token::Operator") and $next eq "->" and $next = $next->snext_sibling and $next->isa("PPI::Token::Word")
!ll&&!rl&&r
15202
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling and $next->isa("PPI::Token::Operator") and $next eq "->" and $next = $next->snext_sibling
!ll&&!rl&&r
15202
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling and $next->isa("PPI::Token::Operator") and $next eq "->"
!ll&&!rl&&r
15202
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling and $next->isa("PPI::Token::Operator")
!ll&&!rl&&r
14932
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling
!ll&&!rl&&r
14905
MC/DC42%3/7
$elem eq "UNIVERSAL" and $next = $elem->snext_sibling and $next->isa("PPI::Token::Operator") and $next eq "->" and $next = $next->snext_sibling and $next->isa("PPI::Token::Word") and $next eq "import"
$elem eq "UNIVERSAL" $next = $elem->snext_sibling $next->isa("PPI::Token::Operator") $next eq "->" $next = $next->snext_sibling $next->isa("PPI::Token::Word") $next eq "import"
Truth table50%4/8
A and B and C and D and E and F and G
A= $elem eq "UNIVERSAL"B= $next = $elem->snext_siblingC= $next->isa("PPI::Token::Operator")D= $next eq "->"E= $next = $next->snext_siblingF= $next->isa("PPI::Token::Word")G= $next eq "import"
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11110XX0
111110X0
11111100
11111111
99 and $next = $elem->snext_sibling and $next->isa('PPI::Token::Operator') and $next eq '->'
100 and $next = $next->snext_sibling and $next->isa('PPI::Token::Word') and $next eq 'import') {
101 1 push @violations, $self->_violation('UNIVERSAL->import()', $next);
102 # for $x qw(...)
103 ▶ } elsif (($elem eq 'for' or $elem eq 'foreach') and !$elem->sprevious_sibling) {
Condition83%5/6
$elem eq "for" || $elem eq "foreach" and not $elem->sprevious_sibling
!ll&&!rl&&r
15012
$elem eq "for" or $elem eq "foreach"
l!l&&r!l&&!r
30150
MC/DC66%2/3
$elem eq "for" || $elem eq "foreach" and not $elem->sprevious_sibling
$elem eq "for" $elem eq "foreach" not $elem->sprevious_sibling
Truth table60%3/5
A or B and not(C)
A= $elem eq "for"B= $elem eq "foreach"C= not $elem->sprevious_sibling
ABCresult
00X0
1X00
0100
1X11
0111
104 2 $next = $elem->snext_sibling;
105 2 ▶ until (!$next or $next->isa('PPI::Structure::List')
Branch: 1 branch
BranchTrueFalseTotal
unless (not $next or $next->isa("PPI::Structure::List") or $next->isa("PPI::Token::QuoteLike::Words")) 4 2 6
Condition83%5/6
not $next or $next->isa("PPI::Structure::List") or $next->isa("PPI::Token::QuoteLike::Words")
l!l&&r!l&&!r
114
not $next or $next->isa("PPI::Structure::List")
l!l&&r!l&&!r
015
MC/DC66%2/3
not $next or $next->isa("PPI::Structure::List") or $next->isa("PPI::Token::QuoteLike::Words")
not $next $next->isa("PPI::Structure::List") $next->isa("PPI::Token::QuoteLike::Words")
Truth table75%3/4
not(A) or B or C
A= not $nextB= $next->isa("PPI::Structure::List")C= $next->isa("PPI::Token::QuoteLike::Words")
ABCresult
1XX1
01X1
0011
0000
106 or $next->isa('PPI::Token::QuoteLike::Words')) {
107 4 $next = $next->snext_sibling;
108 }
109 2 ▶ if ($next and $next->isa('PPI::Token::QuoteLike::Words')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and $next->isa("PPI::Token::QuoteLike::Words")) 1 1 2
Condition66%2/3
$next and $next->isa("PPI::Token::QuoteLike::Words")
!ll&&!rl&&r
011
MC/DC50%1/2
$next and $next->isa("PPI::Token::QuoteLike::Words")
$next $next->isa("PPI::Token::QuoteLike::Words")
Truth table66%2/3
A and B
A= $nextB= $next->isa("PPI::Token::QuoteLike::Words")
ABresult
0X0
100
111
110 1 push @violations, $self->_violation('qw(...) as parentheses', $next);
111 }
112 # do SUBROUTINE(LIST)
113 ▶ } elsif ($elem eq 'do' and $next = $elem->snext_sibling) {
Condition66%2/3
$elem eq "do" and $next = $elem->snext_sibling
!ll&&!rl&&r
14506
MC/DC50%1/2
$elem eq "do" and $next = $elem->snext_sibling
$elem eq "do" $next = $elem->snext_sibling
Truth table66%2/3
A and B
A= $elem eq "do"B= $next = $elem->snext_sibling
ABresult
0X0
100
111
114 6 ▶ if ((($next->isa('PPI::Token::Word') and is_function_call $next)
Branch: 1 branch
BranchTrueFalseTotal
if ($next->isa("PPI::Token::Word") && is_function_call($next) || $next->isa("PPI::Token::Symbol") && ($next->raw_type eq "&" || $next->raw_type eq "\$") and ($next = $next->snext_sibling and $next->isa("PPI::Structure::List"))) 3 3 6
Condition77%14/18
$next->isa("PPI::Token::Word") && is_function_call($next) || $next->isa("PPI::Token::Symbol") && ($next->raw_type eq "&" || $next->raw_type eq "\$") and ($next = $next->snext_sibling and $next->isa("PPI::Structure::List"))
!ll&&!rl&&r
213
$next->isa("PPI::Token::Word") and is_function_call($next) or $next->isa("PPI::Token::Symbol") and $next->raw_type eq "&" || $next->raw_type eq "\$"
l!l&&r!l&&!r
132
$next->isa("PPI::Token::Word") and is_function_call($next)
!ll&&!rl&&r
501
$next->isa("PPI::Token::Symbol") and $next->raw_type eq "&" || $next->raw_type eq "\$"
!ll&&!rl&&r
203
$next->raw_type eq "&" or $next->raw_type eq "\$"
l!l&&r!l&&!r
120
$next = $next->snext_sibling and $next->isa("PPI::Structure::List")
!ll&&!rl&&r
013
MC/DC42%3/7
$next->isa("PPI::Token::Word") && is_function_call($next) || $next->isa("PPI::Token::Symbol") && ($next->raw_type eq "&" || $next->raw_type eq "\$") and ($next = $next->snext_sibling and $next->isa("PPI::Structure::List"))
$next->isa("PPI::Token::Word") is_function_call($next) $next->isa("PPI::Token::Symbol") $next->raw_type eq "&" $next->raw_type eq "\$" $next = $next->snext_sibling $next->isa("PPI::Structure::List")
Truth table26%5/19
A and B or C and D or E and F and G
A= $next->isa("PPI::Token::Word")B= is_function_call($next)C= $next->isa("PPI::Token::Symbol")D= $next->raw_type eq "&"E= $next->raw_type eq "\$"F= $next = $next->snext_siblingG= $next->isa("PPI::Structure::List")
ABCDEFGresult
0X0XXXX0
0X100XX0
100XXXX0
10100XX0
11XXX0X0
11XXX100
0X11X0X0
0X11X100
0X1010X0
0X101100
1011X0X0
1011X100
101010X0
10101100
11XXX111
0X11X111
0X101111
1011X111
10101111
115 or ($next->isa('PPI::Token::Symbol') and ($next->raw_type eq '&' or $next->raw_type eq '$')))
116 and ($next = $next->snext_sibling and $next->isa('PPI::Structure::List'))) {
117 3 push @violations, $self->_violation('do SUBROUTINE(LIST)', $elem);
118 }
119 # avoid false positives for method calls
120 ▶ } elsif (!($prev = $elem->sprevious_sibling) or !$prev->isa('PPI::Token::Operator') or $prev ne '->') {
Condition100%6/6
not +($prev = $elem->sprevious_sibling) && $prev->isa("PPI::Token::Operator") or $prev ne "->"
l!l&&r!l&&!r
13294
($prev = $elem->sprevious_sibling) && $prev->isa('PPI::Token::Operator')
!ll&&!rl&&r
1151713
MC/DC100%3/3
not +($prev = $elem->sprevious_sibling) && $prev->isa("PPI::Token::Operator") or $prev ne "->"
($prev = $elem->sprevious_sibling) $prev->isa('PPI::Token::Operator') $prev ne "->"
Truth table100%4/4
not(A && B) or C
A= ($prev = $elem->sprevious_sibling)B= $prev->isa('PPI::Token::Operator')C= $prev ne "->"
ABCresult
0XX1
10X1
1111
1100
121 # POSIX character function or POSIX::tmpnam()
122 141 ▶ if (exists $posix_deprecated{$elem} or $elem eq 'tmpnam' or $elem eq 'POSIX::tmpnam') {
Branch: 4 branches
BranchTrueFalseTotal
if (exists $posix_deprecated{$elem} or $elem eq 'tmpnam' or $elem eq 'POSIX::tmpnam') { } 48 93 141
elsif ($elem eq 'defined' and $next = $elem->snext_sibling) { } 8 85 93
elsif (exists $autoderef_functions{$elem} and $next = $elem->snext_sibling) { } 21 64 85
elsif ($elem eq 'chdir' and $next = $elem->snext_sibling) { } 7 114 121
Condition100%6/6
exists $posix_deprecated{$elem} or $elem eq "tmpnam" or $elem eq "POSIX::tmpnam"
l!l&&r!l&&!r
47193
exists $posix_deprecated{$elem} or $elem eq "tmpnam"
l!l&&r!l&&!r
44394
MC/DC100%3/3
exists $posix_deprecated{$elem} or $elem eq "tmpnam" or $elem eq "POSIX::tmpnam"
exists $posix_deprecated{$elem} $elem eq "tmpnam" $elem eq "POSIX::tmpnam"
Truth table100%4/4
A or B or C
A= exists $posix_deprecated{$elem}B= $elem eq "tmpnam"C= $elem eq "POSIX::tmpnam"
ABCresult
1XX1
01X1
0011
0000
123 48 ▶ my $is_posix = $elem =~ m/^POSIX::/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$elem =~ /^POSIX::/ ? : 12 36 48
124 48 (my $function_name = $elem) =~ s/^POSIX:://;
125 48 ▶ unless ($is_posix) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_posix) 36 12 48
126 36 ▶ my $includes = $elem->document->find('PPI::Statement::Include') || [];
Condition50%1/2
$elem->document->find('PPI::Statement::Include') || []
l!l
360
MC/DC0%0/1
$elem->document->find('PPI::Statement::Include') || []
$elem->document->find('PPI::Statement::Include')
Truth table50%1/2
A
A= $elem->document->find('PPI::Statement::Include')
Aresult
11
00
127 36 ▶ foreach my $stmt (grep { ($_->module // '') eq 'POSIX' } @$includes) {
Condition50%1/2
$_->module // ""
l!l
960
MC/DC0%0/1
$_->module // ""
$_->module
Truth table50%1/2
A
A= $_->module
Aresult
11
00
128 36 my @args = $stmt->arguments;
129 36 ▶ $is_posix = 1 if !@args or any { $_ =~ m/\b\Q$function_name\E\b/ } @args;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if not @args or &any(sub { $_ =~ /\b\Q$function_name\E\b/; } , @args) 24 12 36
Condition100%3/3
not @args or &any(sub { $_ =~ /\b\Q$function_name\E\b/; } , @args)
l!l&&r!l&&!r
121212
MC/DC100%2/2
not @args or &any(sub { $_ =~ /\b\Q$function_name\E\b/; } , @args)
not @args &any(sub { $_ =~ /\b\Q$function_name\E\b/; } , @args)
Truth table100%3/3
not(A) or B
A= not @argsB= &any(sub { $_ =~ /\b\Q$function_name\E\b/; } , @args)
ABresult
1X1
011
000
130 }
131 }
132 48 ▶ if ($is_posix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_posix) 36 12 48
133 36 ▶ push @violations, $self->_violation('POSIX::tmpnam()', $elem) if $function_name eq 'tmpnam';
Branch: 1 branch
BranchTrueFalseTotal
if $function_name eq "tmpnam" 3 33 36
134 36 ▶ push @violations, $self->_violation('POSIX character function', $elem) if exists $posix_deprecated{$elem};
Branch: 1 branch
BranchTrueFalseTotal
if exists $posix_deprecated{$elem} 33 3 36
135 }
136 # defined array/hash
137 ▶ } elsif ($elem eq 'defined' and $next = $elem->snext_sibling) {
Condition66%2/3
$elem eq "defined" and $next = $elem->snext_sibling
!ll&&!rl&&r
8508
MC/DC50%1/2
$elem eq "defined" and $next = $elem->snext_sibling
$elem eq "defined" $next = $elem->snext_sibling
Truth table66%2/3
A and B
A= $elem eq "defined"B= $next = $elem->snext_sibling
ABresult
0X0
100
111
138 8 ▶ $next = $next->schild(0) if $next->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
if $next->isa("PPI::Structure::List") 2 6 8
139 8 ▶ if ($next and $next->isa('PPI::Token::Symbol')
Branch: 1 branch
BranchTrueFalseTotal
if ($next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\@" || $next->raw_type eq "%" and $next->raw_type eq $next->symbol_type) 2 6 8
Condition83%10/12
$next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\@" || $next->raw_type eq "%" and $next->raw_type eq $next->symbol_type
!ll&&!rl&&r
602
$next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\@" || $next->raw_type eq "%"
!ll&&!rl&&r
242
$next and $next->isa("PPI::Token::Symbol")
!ll&&!rl&&r
026
$next->raw_type eq "\@" or $next->raw_type eq "%"
l!l&&r!l&&!r
114
MC/DC60%3/5
$next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\@" || $next->raw_type eq "%" and $next->raw_type eq $next->symbol_type
$next $next->isa("PPI::Token::Symbol") $next->raw_type eq "\@" $next->raw_type eq "%" $next->raw_type eq $next->symbol_type
Truth table57%4/7
A and B and C or D and E
A= $nextB= $next->isa("PPI::Token::Symbol")C= $next->raw_type eq "\@"D= $next->raw_type eq "%"E= $next->raw_type eq $next->symbol_type
ABCDEresult
0XXXX0
10XXX0
1100X0
111X00
110100
111X11
110111
140 and ($next->raw_type eq '@' or $next->raw_type eq '%')
141 and $next->raw_type eq $next->symbol_type) {
142 2 push @violations, $self->_violation('defined on array/hash', $elem);
143 }
144 # autoderef
145 ▶ } elsif (exists $autoderef_functions{$elem} and $next = $elem->snext_sibling) {
Condition66%2/3
exists $autoderef_functions{$elem} and $next = $elem->snext_sibling
!ll&&!rl&&r
64021
MC/DC50%1/2
exists $autoderef_functions{$elem} and $next = $elem->snext_sibling
exists $autoderef_functions{$elem} $next = $elem->snext_sibling
Truth table66%2/3
A and B
A= exists $autoderef_functions{$elem}B= $next = $elem->snext_sibling
ABresult
0X0
100
111
146 21 ▶ $next = $next->schild(0) if $next->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
if $next->isa("PPI::Structure::List") 6 15 21
147 21 ▶ $next = $next->schild(0) if $next and $next->isa('PPI::Statement::Expression');
Branch: 1 branch
BranchTrueFalseTotal
if $next and $next->isa("PPI::Statement::Expression") 5 16 21
Condition100%3/3
$next and $next->isa("PPI::Statement::Expression")
!ll&&!rl&&r
1155
MC/DC100%2/2
$next and $next->isa("PPI::Statement::Expression")
$next $next->isa("PPI::Statement::Expression")
Truth table100%3/3
A and B
A= $nextB= $next->isa("PPI::Statement::Expression")
ABresult
0X0
100
111
148 21 ▶ if ($next and $next->isa('PPI::Token::Symbol') and $next->raw_type eq '$') {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\$") 11 10 21
Condition100%6/6
$next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\$"
!ll&&!rl&&r
8211
$next and $next->isa("PPI::Token::Symbol")
!ll&&!rl&&r
1713
MC/DC100%3/3
$next and $next->isa("PPI::Token::Symbol") and $next->raw_type eq "\$"
$next $next->isa("PPI::Token::Symbol") $next->raw_type eq "\$"
Truth table100%4/4
A and B and C
A= $nextB= $next->isa("PPI::Token::Symbol")C= $next->raw_type eq "\$"
ABCresult
0XX0
10X0
1100
1111
149 11 my $is_postderef;
150 11 ▶ until (!$next or ($next->isa('PPI::Token::Structure') and $next eq ';')
Branch: 1 branch
BranchTrueFalseTotal
unless (not $next or $next->isa("PPI::Token::Structure") and $next eq ";" or $next->isa("PPI::Token::Operator") and $next eq ",") 29 8 37
Condition91%11/12
not $next or $next->isa("PPI::Token::Structure") and $next eq ";" or $next->isa("PPI::Token::Operator") and $next eq ","
l!l&&r!l&&!r
6229
not $next or $next->isa("PPI::Token::Structure") and $next eq ";"
l!l&&r!l&&!r
2431
$next->isa("PPI::Token::Structure") and $next eq ";"
!ll&&!rl&&r
3104
$next->isa("PPI::Token::Operator") and $next eq ","
!ll&&!rl&&r
2182
MC/DC80%4/5
not $next or $next->isa("PPI::Token::Structure") and $next eq ";" or $next->isa("PPI::Token::Operator") and $next eq ","
not $next $next->isa("PPI::Token::Structure") $next eq ";" $next->isa("PPI::Token::Operator") $next eq ","
Truth table62%5/8
not(A) or B and C or D and E
A= not $nextB= $next->isa("PPI::Token::Structure")C= $next eq ";"D= $next->isa("PPI::Token::Operator")E= $next eq ","
ABCDEresult
1XXXX1
011XX1
00X111
010111
00X0X0
00X100
0100X0
010100
151 or ($next->isa('PPI::Token::Operator') and $next eq ',')) {
152 29 $next = $next->snext_sibling;
153 29 ▶ if ($next and $next->isa('PPI::Token::Cast') and ($next eq '@*' or $next eq '%*')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next and $next->isa("PPI::Token::Cast") and $next eq "\@*" || $next eq "%*") 3 26 29
Condition77%7/9
$next and $next->isa("PPI::Token::Cast") and $next eq "\@*" || $next eq "%*"
!ll&&!rl&&r
2603
$next and $next->isa("PPI::Token::Cast")
!ll&&!rl&&r
2243
$next eq "\@*" or $next eq "%*"
l!l&&r!l&&!r
120
MC/DC50%2/4
$next and $next->isa("PPI::Token::Cast") and $next eq "\@*" || $next eq "%*"
$next $next->isa("PPI::Token::Cast") $next eq "\@*" $next eq "%*"
Truth table80%4/5
A and B and C or D
A= $nextB= $next->isa("PPI::Token::Cast")C= $next eq "\@*"D= $next eq "%*"
ABCDresult
0XXX0
10XX0
11000
111X1
11011
154 3 $is_postderef = 1;
155 3 last;
156 }
157 }
158 11 ▶ push @violations, $self->_violation('autoderef', $elem) unless $is_postderef;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_postderef 8 3 11
159 }
160 ▶ } elsif ($elem eq 'chdir' and $next = $elem->snext_sibling) {
Condition66%2/3
$elem eq "chdir" and $next = $elem->snext_sibling
!ll&&!rl&&r
5707
MC/DC50%1/2
$elem eq "chdir" and $next = $elem->snext_sibling
$elem eq "chdir" $next = $elem->snext_sibling
Truth table66%2/3
A and B
A= $elem eq "chdir"B= $next = $elem->snext_sibling
ABresult
0X0
100
111
161 7 ▶ $next = $next->schild(0) if $next->isa('PPI::Structure::List');
Branch: 1 branch
BranchTrueFalseTotal
if $next->isa("PPI::Structure::List") 3 4 7
162 7 ▶ $next = $next->schild(0) if $next and $next->isa('PPI::Statement::Expression');
Branch: 1 branch
BranchTrueFalseTotal
if $next and $next->isa("PPI::Statement::Expression") 2 5 7
Condition100%3/3
$next and $next->isa("PPI::Statement::Expression")
!ll&&!rl&&r
142
MC/DC100%2/2
$next and $next->isa("PPI::Statement::Expression")
$next $next->isa("PPI::Statement::Expression")
Truth table100%3/3
A and B
A= $nextB= $next->isa("PPI::Statement::Expression")
ABresult
0X0
100
111
163 7 ▶ if ($next and (($next->isa('PPI::Token::Quote') and !length $next->string)
Branch: 1 branch
BranchTrueFalseTotal
if ($next and $next->isa("PPI::Token::Quote") && !length($next->string) || $next->isa("PPI::Token::Word") && $next eq "undef") 3 4 7
Condition100%12/12
$next and $next->isa("PPI::Token::Quote") && !length($next->string) || $next->isa("PPI::Token::Word") && $next eq "undef"
!ll&&!rl&&r
133
$next->isa("PPI::Token::Quote") and not length $next->string or $next->isa("PPI::Token::Word") and $next eq "undef"
l!l&&r!l&&!r
213
$next->isa("PPI::Token::Quote") and not length $next->string
!ll&&!rl&&r
312
$next->isa("PPI::Token::Word") and $next eq "undef"
!ll&&!rl&&r
211
MC/DC100%5/5
$next and $next->isa("PPI::Token::Quote") && !length($next->string) || $next->isa("PPI::Token::Word") && $next eq "undef"
$next $next->isa("PPI::Token::Quote") not length $next->string $next->isa("PPI::Token::Word") $next eq "undef"
Truth table75%6/8
A and B and not(C) or D and E
A= $nextB= $next->isa("PPI::Token::Quote")C= not length $next->stringD= $next->isa("PPI::Token::Word")E= $next eq "undef"
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
164 or ($next->isa('PPI::Token::Word') and $next eq 'undef'))) {
165 3 push @violations, $self->_violation('chdir(\'\')', $elem);
166 }
167 }
168 }
169 } elsif ($elem->isa('PPI::Token::Regexp')) {
170 # ?PATTERN?
171 8 ▶ if ($elem->isa('PPI::Token::Regexp::Match') and ($elem->get_delimiters)[0] eq '??' and $elem !~ m/^m/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Regexp::Match") and ($elem->get_delimiters)[0] eq "??" and not $elem =~ /^m/) 0 8 8
Condition83%5/6
$elem->isa("PPI::Token::Regexp::Match") and ($elem->get_delimiters)[0] eq "??" and not $elem =~ /^m/
!ll&&!rl&&r
710
$elem->isa("PPI::Token::Regexp::Match") and ($elem->get_delimiters)[0] eq "??"
!ll&&!rl&&r
341
MC/DC0%0/3
$elem->isa("PPI::Token::Regexp::Match") and ($elem->get_delimiters)[0] eq "??" and not $elem =~ /^m/
$elem->isa("PPI::Token::Regexp::Match") ($elem->get_delimiters)[0] eq "??" not $elem =~ /^m/
Truth table75%3/4
A and B and not(C)
A= $elem->isa("PPI::Token::Regexp::Match")B= ($elem->get_delimiters)[0] eq "??"C= not $elem =~ /^m/
ABCresult
0XX0
10X0
1100
1111
172 0 push @violations, $self->_violation('?PATTERN?', $elem);
173 }
174 8 ▶ if (!$elem->isa('PPI::Token::Regexp::Transliterate')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($elem->isa("PPI::Token::Regexp::Transliterate")) 8 0 8
175 8 push @violations, $self->_violates_interpolated($elem);
176 }
177 } elsif ($elem->isa('PPI::Token::HereDoc')) {
178 # Bare here-doc
179 3 ▶ if ($elem eq '<<') {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem eq "<<") 0 3 3
180 0 push @violations, $self->_violation('Bare here-doc', $elem);
181 }
182 } elsif ($elem->isa('PPI::Token::QuoteLike')) {
183 12 ▶ if ($elem->isa('PPI::Token::QuoteLike::Regexp') or $elem->isa('PPI::Token::QuoteLike::Backtick') or $elem->isa('PPI::Token::QuoteLike::Command')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::QuoteLike::Regexp") or $elem->isa("PPI::Token::QuoteLike::Backtick") or $elem->isa("PPI::Token::QuoteLike::Command")) 8 4 12
Condition100%6/6
$elem->isa("PPI::Token::QuoteLike::Regexp") or $elem->isa("PPI::Token::QuoteLike::Backtick") or $elem->isa("PPI::Token::QuoteLike::Command")
l!l&&r!l&&!r
624
$elem->isa("PPI::Token::QuoteLike::Regexp") or $elem->isa("PPI::Token::QuoteLike::Backtick")
l!l&&r!l&&!r
426
MC/DC100%3/3
$elem->isa("PPI::Token::QuoteLike::Regexp") or $elem->isa("PPI::Token::QuoteLike::Backtick") or $elem->isa("PPI::Token::QuoteLike::Command")
$elem->isa("PPI::Token::QuoteLike::Regexp") $elem->isa("PPI::Token::QuoteLike::Backtick") $elem->isa("PPI::Token::QuoteLike::Command")
Truth table100%4/4
A or B or C
A= $elem->isa("PPI::Token::QuoteLike::Regexp")B= $elem->isa("PPI::Token::QuoteLike::Backtick")C= $elem->isa("PPI::Token::QuoteLike::Command")
ABCresult
1XX1
01X1
0011
0000
184 8 push @violations, $self->_violates_interpolated($elem);
185 }
186 } elsif ($elem->isa('PPI::Token::Quote')) {
187 14 ▶ if ($elem->isa('PPI::Token::Quote::Double') or $elem->isa('PPI::Token::Quote::Interpolate')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elem->isa("PPI::Token::Quote::Double") or $elem->isa("PPI::Token::Quote::Interpolate")) 5 9 14
Condition100%3/3
$elem->isa("PPI::Token::Quote::Double") or $elem->isa("PPI::Token::Quote::Interpolate")
l!l&&r!l&&!r
239
MC/DC100%2/2
$elem->isa("PPI::Token::Quote::Double") or $elem->isa("PPI::Token::Quote::Interpolate")
$elem->isa("PPI::Token::Quote::Double") $elem->isa("PPI::Token::Quote::Interpolate")
Truth table100%3/3
A or B
A= $elem->isa("PPI::Token::Quote::Double")B= $elem->isa("PPI::Token::Quote::Interpolate")
ABresult
1X1
011
000
188 5 push @violations, $self->_violates_interpolated($elem);
189 }
190 }
191 }
192 1165 return @violations;
193 }
194  
195 21 ▶sub _violates_interpolated {
Subroutine _violates_interpolated: called CC=6 SCAR=17.9
196 21 my ($self, $elem) = @_;
197 21 my @violations;
198 # NBSP in \N{...}
199 my $contents;
200 21 ▶ if ($elem->isa('PPI::Token::Regexp') or $elem->isa('PPI::Token::QuoteLike::Regexp')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($elem->isa('PPI::Token::Regexp') or $elem->isa('PPI::Token::QuoteLike::Regexp')) { } 12 9 21
elsif ($elem->isa('PPI::Token::Quote')) { } 5 4 9
Condition100%3/3
$elem->isa("PPI::Token::Regexp") or $elem->isa("PPI::Token::QuoteLike::Regexp")
l!l&&r!l&&!r
849
MC/DC100%2/2
$elem->isa("PPI::Token::Regexp") or $elem->isa("PPI::Token::QuoteLike::Regexp")
$elem->isa("PPI::Token::Regexp") $elem->isa("PPI::Token::QuoteLike::Regexp")
Truth table100%3/3
A or B
A= $elem->isa("PPI::Token::Regexp")B= $elem->isa("PPI::Token::QuoteLike::Regexp")
ABresult
1X1
011
000
201 12 $contents = $elem->get_match_string;
202 # /\C/
203 12 ▶ push @violations, $self->_violation('/\\C/', $elem) if $contents =~ m/(?<!\\)\\C/;
Branch: 1 branch
BranchTrueFalseTotal
if $contents =~ /(?<!\\)\\C/ 2 10 12
204 } elsif ($elem->isa('PPI::Token::Quote')) {
205 5 $contents = $elem->string;
206 } else {
207 # Backticks and qx elements have no contents method
208 4 $contents = $elem;
209 }
210 21 ▶ push @violations, $self->_violation('NBSP in \\N{...}', $elem) if $contents =~ m/\\N\{[^}]*\x{a0}[^}]*\}/;
Branch: 1 branch
BranchTrueFalseTotal
if $contents =~ /\\N\{[^}]*\x{a0}[^}]*\}/ 7 14 21
211 21 return @violations;
212 }
213  
214 1 1;
215  
216 =head1 NAME
217  
218 Perl::Critic::Policy::Community::DeprecatedFeatures - Avoid features that have
219 been deprecated or removed from Perl
220  
221 =head1 DESCRIPTION
222  
223 While L<Perl::Critic::Policy::Community::StrictWarnings> will expose usage of
224 deprecated or removed features when a modern perl is used, this policy will
225 detect such features in use regardless of perl version, to assist in keeping
226 your code modern and forward-compatible.
227  
228 =head1 FEATURES
229  
230 =head2 :=
231  
232 Because the whitespace between an attribute list and assignment operator is not
233 significant, it was possible to specify assignment to a variable with an empty
234 attribute list with a construction like C<my $foo := 'bar'>. This is deprecated
235 in perl v5.12.0 to allow the possibility of a future C<:=> operator. Avoid the
236 issue by either putting whitespace between the C<:> and C<=> characters or
237 simply omitting the empty attribute list.
238  
239 =head2 $[
240  
241 The magic L<perlvar/"$["> variable was used in very old perls to determine the
242 index of the first element of arrays or the first character in substrings, and
243 also allow modifying this value. It was discouraged from the start of Perl 5,
244 its functionality changed in v5.10.0, deprecated in v5.12.0, re-implemented as
245 L<arybase>.pm in v5.16.0, and it is essentially a synonym for C<0> under
246 C<use v5.16> or C<no feature "array_base">. While it is probably a bad idea in
247 general, the modules L<Array::Base> and L<String::Base> can now be used to
248 replace this functionality.
249  
250 =head2 /\C/
251  
252 The C<\C> regular expression character class would match a single byte of the
253 internal representation of the string, which was dangerous because it violated
254 the logical character abstraction of Perl strings, and substitutions using it
255 could result in malformed UTF-8 sequences. It was deprecated in perl v5.20.0
256 and removed in perl v5.24.0. Instead, explicitly encode the string to UTF-8
257 using L<Encode> to examine its UTF-8-encoded byte representation.
258  
259 =head2 ?PATTERN?
260  
261 The C<?PATTERN?> regex match syntax is deprecated in perl v5.14.0 and removed
262 in perl v5.22.0. Use C<m?PATTERN?> instead.
263  
264 =head2 autoderef
265  
266 An experimental feature was introduced in perl v5.14.0 to allow calling various
267 builtin functions (which operate on arrays or hashes) on a reference, which
268 would automatically dereference the operand. This led to ambiguity when passed
269 objects that overload both array and hash dereferencing, and so was removed in
270 perl v5.24.0. Instead, explicitly dereference the reference when calling these
271 functions. The functions affected are C<each>, C<keys>, C<pop>, C<push>,
272 C<shift>, C<splice>, C<unshift>, and C<values>.
273  
274 =head2 Bare here-doc
275  
276 Using C< << > to initiate a here-doc would create it with an empty terminator,
277 similar to C< <<'' >, so the here-doc would terminate on the next empty line.
278 Omitting the quoted empty string has been deprecated since perl 5, and is a
279 fatal error in perl v5.28.0.
280  
281 =head2 chdir('')
282  
283 Passing an empty string or C<undef> to C<chdir()> would change to the home
284 directory, but this usage is deprecated in perl v5.8.0 and throws an error in
285 perl v5.24.0. Instead, call C<chdir()> with no arguments for this behavior.
286  
287 =head2 defined on array/hash
288  
289 Using the function C<defined()> on an array or hash probably does not do what
290 you expected, and is deprecated in perl v5.6.2 and throws a fatal error in perl
291 v5.22.0. To check if an array or hash is non-empty, test if it has elements.
292  
293 if (@foo) { ... }
294 if (keys %bar) { ... }
295  
296 =head2 do SUBROUTINE(LIST)
297  
298 This form of C<do> to call a subroutine has been deprecated since perl 5, and
299 is removed in perl v5.20.0.
300  
301 =head2 NBSP in \N{...}
302  
303 Use of the "no-break space" character in L<character names|charnames> is
304 deprecated in perl v5.22.0 and an error in perl v5.26.0.
305  
306 =head2 POSIX character functions
307  
308 Several character matching functions in L<POSIX>.pm are deprecated in perl
309 v5.20.0. See the L<POSIX> documentation for more details. Most uses of these
310 functions can be replaced with appropriate regex matches.
311  
312 isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, issuper, isxdigit
313  
314 =head2 POSIX::tmpnam()
315  
316 The C<tmpnam()> function from L<POSIX>.pm is deprecated in perl v5.22.0 and
317 removed in perl v5.26.0. Use L<File::Temp> instead.
318  
319 =head2 qw(...) as parentheses
320  
321 Literal parentheses are required for certain statements such as a
322 C<for my $foo (...) { ... }> construct. Using a C<qw(...)> list literal without
323 surrounding parentheses in this syntax is deprecated in perl v5.14.0 and a
324 syntax error in perl v5.18.0. Wrap the literal in parentheses:
325 C<for my $foo (qw(...)) { ... }>.
326  
327 =head2 require ::Foo::Bar
328  
329 A bareword C<require> (or C<use>) starting with a double colon would
330 inadvertently translate to a path starting with C</>. Starting in perl v5.26.0,
331 this is a fatal error.
332  
333 =head2 UNIVERSAL->import()
334  
335 The method C<< UNIVERSAL->import() >> and similarly passing import arguments to
336 C<use UNIVERSAL> is deprecated in perl v5.12.0 and throws a fatal error in perl
337 v5.22.0. Calling C<use UNIVERSAL> with no arguments is not an error, but serves
338 no purpose.
339  
340 =head1 AFFILIATION
341  
342 This policy is part of L<Perl::Critic::Community>.
343  
344 =head1 CONFIGURATION
345  
346 This policy is not configurable except for the standard options.
347  
348 =head1 CAVEATS
349  
350 This policy is incomplete, as many deprecations are difficult to test for
351 statically. It is recommended to use L<perlbrew> or L<perl-build> to test your
352 code under newer versions of Perl, with C<warnings> enabled.
353  
354 =head1 AUTHOR
355  
356 Dan Book, C<dbook@cpan.org>
357  
358 =head1 COPYRIGHT AND LICENSE
359  
360 Copyright 2015, Dan Book.
361  
362 This library is free software; you may redistribute it and/or modify it under
363 the terms of the Artistic License version 2.0.
364  
365 =head1 SEE ALSO
366  
367 L<Perl::Critic>
↑ Summary Policy/Community/MultidimensionalArrayEmulation.pm »