Perl/Lint/Policy/Modules/RequireEndWithOne.pm

filter: Statementstmt 54.2% 19 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 27 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 28.7% 25 / 87 CC 13 SCAR 48.3
CC
13
Cov
28%
evaluate
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 124.8
« Perl/Lint/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm ↑ Summary Perl/Lint/Policy/Modules/RequireExplicitPackage.pm »
1 package Perl::Lint::Policy::Modules::RequireEndWithOne;
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 utf8;
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 => 'Module does not end with "1;"',
10 EXPL => 'Must end with a recognizable true value',
11 2 };
12  
13 0 ▶sub evaluate {
Subroutine evaluate: not called CC=13 SCAR=52.0
Pod undocumented
14 0 my ($class, $file, $tokens, $src, $args) = @_;
15  
16 0 my @violations;
17 0 ▶ if ($src =~ /\A#!/) { # for shebang. If
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ /\A#!/) 0 0 0
18 0 return [];
19 }
20  
21 0 my $last_token = $tokens->[-1];
22 0 my $last_token_type = $last_token->{type};
23 0 my $last_token_data = $last_token->{data};
24 0 my $before_last_token = $tokens->[-2];
25 0 my $before_last_token_type = $before_last_token->{type};
26 0 my $before_last_token_data = $before_last_token->{data};
27 0 my $extra_before_token = $tokens->[-3];
28  
29 0 ▶ if (!%$last_token || !%$before_last_token) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%$last_token and %$before_last_token) 0 0 0
Condition0%0/3
%$last_token and %$before_last_token
!ll&&!rl&&r
000
MC/DC0%0/2
%$last_token and %$before_last_token
%$last_token %$before_last_token
Truth table0%0/3
A and B
A= %$last_tokenB= %$before_last_token
ABresult
0X0
100
111
30 0 return [];
31 }
32  
33 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($before_last_token_type == 65 and $last_token_type == 122 and $last_token_data eq "pod" or !$extra_before_token || $extra_before_token->{"type"} == 106 || $extra_before_token->{"type"} == 110 and $before_last_token_type == 170 and $last_token_type == 106 and eval $before_last_token_data == 1) 0 0 0
Condition0%0/24
$before_last_token_type == 65 and $last_token_type == 122 and $last_token_data eq "pod" or !$extra_before_token || $extra_before_token->{"type"} == 106 || $extra_before_token->{"type"} == 110 and $before_last_token_type == 170 and $last_token_type == 106 and eval $before_last_token_data == 1
l!l&&r!l&&!r
000
$before_last_token_type == 65 and $last_token_type == 122 and $last_token_data eq "pod"
!ll&&!rl&&r
000
$before_last_token_type == 65 and $last_token_type == 122
!ll&&!rl&&r
000
!$extra_before_token || $extra_before_token->{"type"} == 106 || $extra_before_token->{"type"} == 110 and $before_last_token_type == 170 and $last_token_type == 106 and eval $before_last_token_data == 1
!ll&&!rl&&r
000
!$extra_before_token || $extra_before_token->{"type"} == 106 || $extra_before_token->{"type"} == 110 and $before_last_token_type == 170 and $last_token_type == 106
!ll&&!rl&&r
000
!$extra_before_token || $extra_before_token->{"type"} == 106 || $extra_before_token->{"type"} == 110 and $before_last_token_type == 170
!ll&&!rl&&r
000
not $extra_before_token or $extra_before_token->{"type"} == 106 or $extra_before_token->{"type"} == 110
l!l&&r!l&&!r
000
not $extra_before_token or $extra_before_token->{"type"} == 106
l!l&&r!l&&!r
000
MC/DC0%0/9
$before_last_token_type == 65 and $last_token_type == 122 and $last_token_data eq "pod" or !$extra_before_token || $extra_before_token->{"type"} == 106 || $extra_before_token->{"type"} == 110 and $before_last_token_type == 170 and $last_token_type == 106 and eval $before_last_token_data == 1
$before_last_token_type == 65 $last_token_type == 122 $last_token_data eq "pod" not $extra_before_token $extra_before_token->{"type"} == 106 $extra_before_token->{"type"} == 110 $before_last_token_type == 170 $last_token_type == 106 eval $before_last_token_data == 1
Truth table0%0/40
A and B and C or not(D) or E or F and G and H and I
A= $before_last_token_type == 65B= $last_token_type == 122C= $last_token_data eq "pod"D= not $extra_before_tokenE= $extra_before_token->{"type"} == 106F= $extra_before_token->{"type"} == 110G= $before_last_token_type == 170H= $last_token_type == 106I= eval $before_last_token_data == 1
ABCDEFGHIresult
111XXXXXX1
0XX1XX1111
0XX01X1111
0XX0011111
10X1XX1111
10X01X1111
10X0011111
1101XX1111
11001X1111
1100011111
0XX000XXX0
0XX1XX0XX0
0XX01X0XX0
0XX0010XX0
0XX1XX10X0
0XX01X10X0
0XX00110X0
0XX1XX1100
0XX01X1100
0XX0011100
10X000XXX0
10X1XX0XX0
10X01X0XX0
10X0010XX0
10X1XX10X0
10X01X10X0
10X00110X0
10X1XX1100
10X01X1100
10X0011100
110000XXX0
1101XX0XX0
11001X0XX0
1100010XX0
1101XX10X0
11001X10X0
11000110X0
1101XX1100
11001X1100
1100011100
34 !(
35 $before_last_token_type == ASSIGN &&
36 $last_token_type == KEY &&
37 $last_token_data eq 'pod'
38 ) &&
39 !(
40 (
41 !$extra_before_token ||
42 $extra_before_token->{type} == SEMI_COLON ||
43 $extra_before_token->{type} == RIGHT_BRACE
44 ) &&
45 $before_last_token_type == INT &&
46 $last_token_type == SEMI_COLON &&
47 eval($before_last_token_data) == 1 ## no critic: to accept bin, oct and hex decimal
48 )
49 ) {
50 push @violations, {
51 filename => $file,
52 line => $last_token->{line},
53 0 description => DESC,
54 explanation => EXPL,
55 policy => __PACKAGE__,
56 };
57 }
58  
59 0 return \@violations;
60 }
61  
62 2 1;
63  
« Perl/Lint/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm ↑ Summary Perl/Lint/Policy/Modules/RequireExplicitPackage.pm »