Perl/Lint/Policy/ValuesAndExpressions/ProhibitSpecialHeredocTerminator.pm

filter: Statementstmt 88.0% 22 / 25 Branchbran 50.0% 3 / 6 Conditioncond 11.1% 2 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 51.5% 33 / 64 CC 10 SCAR 32.9
CC
10
Cov
55%
evaluate
39.6
BEGIN
1.0
BEGIN
1.0
CRAP 26.8
« Perl/Lint/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm ↑ Summary Perl/Lint/Policy/Subroutines/ProhibitAmpersandSigils.pm »
1 package Perl::Lint::Policy::ValuesAndExpressions::ProhibitSpecialHeredocTerminator;
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 => 'Heredoc terminator must not be a special literal',
9 EXPL => 'Used "%s" as heredoc terminator',
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=10 SCAR=36.8
Pod undocumented
13 2 my ($class, $file, $tokens, $args) = @_;
14  
15 2 my @violations;
16 2 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 51 2 53
17 51 my $token_type = $token->{type};
18 51 ▶ if ($token_type == HERE_DOCUMENT_TAG || $token_type == HERE_DOCUMENT_RAW_TAG || $token_type == HERE_DOCUMENT_BARE_TAG) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 176 or $token_type == 177 or $token_type == 179) 0 51 51
Condition33%2/6
$token_type == 176 or $token_type == 177 or $token_type == 179
l!l&&r!l&&!r
0051
$token_type == 176 or $token_type == 177
l!l&&r!l&&!r
0051
MC/DC0%0/3
$token_type == 176 or $token_type == 177 or $token_type == 179
$token_type == 176 $token_type == 177 $token_type == 179
Truth table25%1/4
A or B or C
A= $token_type == 176B= $token_type == 177C= $token_type == 179
ABCresult
1XX1
01X1
0011
0000
19 0 my $token_data = $token->{data};
20 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($token_data eq "__FILE__" or $token_data eq "__LINE__" or $token_data eq "__PACKAGE__" or $token_data eq "__END__" or $token_data eq "__DATA__") 0 0 0
Condition0%0/12
$token_data eq "__FILE__" or $token_data eq "__LINE__" or $token_data eq "__PACKAGE__" or $token_data eq "__END__" or $token_data eq "__DATA__"
l!l&&r!l&&!r
000
$token_data eq "__FILE__" or $token_data eq "__LINE__" or $token_data eq "__PACKAGE__" or $token_data eq "__END__"
l!l&&r!l&&!r
000
$token_data eq "__FILE__" or $token_data eq "__LINE__" or $token_data eq "__PACKAGE__"
l!l&&r!l&&!r
000
$token_data eq "__FILE__" or $token_data eq "__LINE__"
l!l&&r!l&&!r
000
MC/DC0%0/5
$token_data eq "__FILE__" or $token_data eq "__LINE__" or $token_data eq "__PACKAGE__" or $token_data eq "__END__" or $token_data eq "__DATA__"
$token_data eq "__FILE__" $token_data eq "__LINE__" $token_data eq "__PACKAGE__" $token_data eq "__END__" $token_data eq "__DATA__"
Truth table0%0/6
A or B or C or D or E
A= $token_data eq "__FILE__"B= $token_data eq "__LINE__"C= $token_data eq "__PACKAGE__"D= $token_data eq "__END__"E= $token_data eq "__DATA__"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
21 $token_data eq '__FILE__' ||
22 $token_data eq '__LINE__' ||
23 $token_data eq '__PACKAGE__' ||
24 $token_data eq '__END__' ||
25 $token_data eq '__DATA__'
26 ) {
27 push @violations, {
28 filename => $file,
29 line => $token->{line},
30 0 description => DESC,
31 explanation => sprintf(EXPL, $token_data),
32 policy => __PACKAGE__,
33 };
34 }
35 }
36 }
37  
38 2 return \@violations;
39 }
40  
41 3 1;
42  
« Perl/Lint/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm ↑ Summary Perl/Lint/Policy/Subroutines/ProhibitAmpersandSigils.pm »