Perl/Lint/Policy/ValuesAndExpressions/ProhibitEscapedCharacters.pm

filter: Statementstmt 86.6% 26 / 30 Branchbran 70.0% 7 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 80.7% 42 / 52 CC 7 SCAR 16.6
CC
7
Cov
81%
evaluate
8.3
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« Perl/Lint/Policy/ControlStructures/ProhibitCStyleForLoops.pm ↑ Summary Perl/Lint/Policy/Subroutines/ProhibitSubroutinePrototypes.pm »
1 package Perl::Lint::Policy::ValuesAndExpressions::ProhibitEscapedCharacters;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 DESC => 'Numeric escapes in interpolated string',
9 EXPL => [54, 55],
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=7 SCAR=21.1
Pod undocumented
13 2 my ($class, $file, $tokens, $args) = @_;
14  
15 2 my @violations;
16 2 my $is_reg_quote = 0;
17 2 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
18 51 my $token_type = $token->{type};
19 51 ▶ if ($token_type == REG_QUOTE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 145) { } 0 51 51
elsif ($token_type == 172 or $token_type == 187) { } 2 49 51
20 0 $is_reg_quote = 1;
21 }
22 ▶ elsif ($token_type == STRING || $token_type == REG_EXP) {
Condition66%2/3
$token_type == 172 or $token_type == 187
l!l&&r!l&&!r
0249
MC/DC50%1/2
$token_type == 172 or $token_type == 187
$token_type == 172 $token_type == 187
Truth table66%2/3
A or B
A= $token_type == 172B= $token_type == 187
ABresult
1X1
011
000
23 2 ▶ if ($is_reg_quote) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_reg_quote) 0 2 2
24 0 $is_reg_quote = 0;
25 0 next;
26 }
27  
28 2 my $string = $token->{data};
29 2 ▶ if ($string =~ /\\x?[0-9a-fA-F]{2,}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ /\\x?[0-9a-fA-F]{2,}/) 0 2 2
30 push @violations, {
31 filename => $file,
32 line => $token->{line},
33 0 description => DESC,
34 explanation => EXPL,
35 policy => __PACKAGE__,
36 };
37 }
38 }
39 }
40  
41 2 return \@violations;
42 }
43  
44 3 1;
45  
« Perl/Lint/Policy/ControlStructures/ProhibitCStyleForLoops.pm ↑ Summary Perl/Lint/Policy/Subroutines/ProhibitSubroutinePrototypes.pm »