Perl/Lint/Policy/ValuesAndExpressions/RequireUpperCaseHeredocTerminator.pm

filter: Statementstmt 82.7% 24 / 29 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 64.9% 37 / 57 CC 8 SCAR 23.3
CC
8
Cov
67%
evaluate
16.0
BEGIN
1.0
BEGIN
1.0
CRAP 10.2
« Perl/Lint/Policy/ValuesAndExpressions/RequireNumberSeparators.pm ↑ Summary Perl/Lint/Policy/ClassHierarchies/ProhibitAutoloading.pm »
1 package Perl::Lint::Policy::ValuesAndExpressions::RequireUpperCaseHeredocTerminator;
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 be quoted',
9 EXPL => [64],
10 3 };
11  
12 2 ▶sub evaluate {
Subroutine evaluate: called CC=8 SCAR=27.7
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  
19 # XXX workaround
20 # Compiler::Lexer cannot recognize heredoc tag as bare word and lowercase
21 # https://github.com/goccy/p5-Compiler-Lexer/issues/37
22 #
23 # e.g.
24 # <<endquote
25 51 my $is_before_left_shift = 0;
26 51 ▶ if ($token_type == LEFT_SHIFT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 50) 0 51 51
27 0 $token = $tokens->[++$i];
28 0 $token_type = $token->{type};
29 0 $is_before_left_shift = 1;
30 }
31  
32 51 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 176 or $token_type == 177 or $is_before_left_shift and $token_type == 122) 0 51 51
Condition33%3/9
$token_type == 176 or $token_type == 177 or $is_before_left_shift and $token_type == 122
l!l&&r!l&&!r
0051
$token_type == 176 or $token_type == 177
l!l&&r!l&&!r
0051
$is_before_left_shift and $token_type == 122
!ll&&!rl&&r
5100
MC/DC0%0/4
$token_type == 176 or $token_type == 177 or $is_before_left_shift and $token_type == 122
$token_type == 176 $token_type == 177 $is_before_left_shift $token_type == 122
Truth table20%1/5
A or B or C and D
A= $token_type == 176B= $token_type == 177C= $is_before_left_shiftD= $token_type == 122
ABCDresult
1XXX1
01XX1
00111
000X0
00100
33 $token_type == HERE_DOCUMENT_TAG ||
34 $token_type == HERE_DOCUMENT_RAW_TAG ||
35 ($is_before_left_shift && $token_type == KEY)
36 ) {
37 0 ▶ if ($token->{data} =~ /[a-z]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ /[a-z]/) 0 0 0
38 push @violations, {
39 filename => $file,
40 line => $token->{line},
41 0 description => DESC,
42 explanation => EXPL,
43 policy => __PACKAGE__,
44 };
45 }
46 }
47 }
48  
49 2 return \@violations;
50 }
51  
52 3 1;
53  
« Perl/Lint/Policy/ValuesAndExpressions/RequireNumberSeparators.pm ↑ Summary Perl/Lint/Policy/ClassHierarchies/ProhibitAutoloading.pm »