Perl/Lint/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 25.0% 25 / 100 CC 17 SCAR 54.2
CC
17
Cov
24%
evaluate
306.0
BEGIN
1.0
BEGIN
1.0
CRAP 226.4
« Perl/Lint/Policy/BuiltinFunctions/ProhibitBooleanGrep.pm ↑ Summary Perl/Lint/Policy/TestingAndDebugging/ProhibitNoStrict.pm »
1 package Perl::Lint::Policy::InputOutput::RequireEncodingWithUTF8Layer;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Perl::Lint::Constants::Kind;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 DESC => 'I/O layer ":utf8" used',
10 EXPL => 'Use ":encoding(UTF-8)" to get strict validation',
11 2 };
12  
13 0 ▶sub evaluate {
Subroutine evaluate: not called CC=17 SCAR=57.2
Pod undocumented
14 0 my ($class, $file, $tokens, $src, $args) = @_;
15  
16 0 my @violations;
17 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
18 0 my $token_type = $token->{type};
19 0 my $token_data = $token->{data};
20  
21 0 ▶ if ($token_type == BUILTIN_FUNC && ($token_data eq 'open' || $token_data eq 'binmode')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 and $token_data eq "open" || $token_data eq "binmode") 0 0 0
Condition0%0/6
$token_type == 70 and $token_data eq "open" || $token_data eq "binmode"
!ll&&!rl&&r
000
$token_data eq "open" or $token_data eq "binmode"
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_type == 70 and $token_data eq "open" || $token_data eq "binmode"
$token_type == 70 $token_data eq "open" $token_data eq "binmode"
Truth table0%0/4
A and B or C
A= $token_type == 70B= $token_data eq "open"C= $token_data eq "binmode"
ABCresult
0XX0
1000
11X1
1011
22 0 my @args;
23 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
24 0 my $token_type = $token->{type};
25 0 my $token_kind = $token->{kind};
26 0 ▶ if ($token_type == RIGHT_PAREN || $token_kind == KIND_STMT_END || $token_kind == KIND_OP) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 108 or $token_kind == 21 or $token_kind == 1) { } 0 0 0
elsif ($token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_type != 107 and $token_kind != 3) { } 0 0 0
Condition0%0/6
$token_type == 108 or $token_kind == 21 or $token_kind == 1
l!l&&r!l&&!r
000
$token_type == 108 or $token_kind == 21
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_type == 108 or $token_kind == 21 or $token_kind == 1
$token_type == 108 $token_kind == 21 $token_kind == 1
Truth table0%0/4
A or B or C
A= $token_type == 108B= $token_kind == 21C= $token_kind == 1
ABCresult
1XX1
01X1
0011
0000
27 0 last;
28 }
29 ▶ elsif (
Condition0%0/15
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_type != 107 and $token_kind != 3
!ll&&!rl&&r
000
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_type != 107
!ll&&!rl&&r
000
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151
!ll&&!rl&&r
000
$token_type != 104 and $token_type != 146 and $token_type != 145
!ll&&!rl&&r
000
$token_type != 104 and $token_type != 146
!ll&&!rl&&r
000
MC/DC0%0/6
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_type != 107 and $token_kind != 3
$token_type != 104 $token_type != 146 $token_type != 145 $token_type != 151 $token_type != 107 $token_kind != 3
Truth table0%0/7
A and B and C and D and E and F
A= $token_type != 104B= $token_type != 146C= $token_type != 145D= $token_type != 151E= $token_type != 107F= $token_kind != 3
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
30 $token_type != COMMA &&
31 $token_type != REG_DOUBLE_QUOTE &&
32 $token_type != REG_QUOTE &&
33 $token_type != REG_DELIM &&
34 $token_type != LEFT_PAREN &&
35 $token_kind != KIND_DECL
36 ) {
37 0 push @args, $token->{data};
38 }
39 }
40 0 my $second_arg = $args[1];
41 0 ▶ if ($second_arg && $second_arg =~ /utf8\Z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($second_arg and $second_arg =~ /utf8\Z/) 0 0 0
Condition0%0/3
$second_arg and $second_arg =~ /utf8\Z/
!ll&&!rl&&r
000
MC/DC0%0/2
$second_arg and $second_arg =~ /utf8\Z/
$second_arg $second_arg =~ /utf8\Z/
Truth table0%0/3
A and B
A= $second_argB= $second_arg =~ /utf8\Z/
ABresult
0X0
100
111
42 push @violations, {
43 filename => $file,
44 line => $token->{line},
45 0 description => DESC,
46 explanation => EXPL,
47 policy => __PACKAGE__,
48 };
49 }
50 }
51  
52 }
53  
54 0 return \@violations;
55 }
56  
57 2 1;
58  
« Perl/Lint/Policy/BuiltinFunctions/ProhibitBooleanGrep.pm ↑ Summary Perl/Lint/Policy/TestingAndDebugging/ProhibitNoStrict.pm »