Perl/Lint/Policy/TestingAndDebugging/RequireUseStrict.pm

filter: Statementstmt 37.9% 22 / 58 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 1 totaltotal 28.4% 29 / 102 CC 15 SCAR 50.6
CC
15
Cov
25%
evaluate
240.0
__ANON__
2.0
BEGIN
1.0
CRAP 156.9
« Perl/Lint/Policy/RegularExpressions/ProhibitEnumeratedClasses.pm ↑ Summary Perl/Lint/Policy/TestingAndDebugging/RequireUseWarnings.pm »
1 package Perl::Lint::Policy::TestingAndDebugging::RequireUseStrict;
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 List::Util qw/any/;
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 EQUIVALENT_PERL_VERSION => 5.011;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 DESC => 'Code before strictures are enabled',
12 EXPL => [429],
13 2 };
14  
15 0 ▶sub evaluate {
Subroutine evaluate: not called CC=15 SCAR=54.8
Pod undocumented
16 0 my ($class, $file, $tokens, $src, $args) = @_;
17  
18 0 my @marshals = ('strict', 'Moose', 'Moose::Role', 'Moose::Util::TypeConstraints');
19 0 ▶ if (my $this_policies_arg = $args->{require_use_strict}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $this_policies_arg = $args->{"require_use_strict"}) 0 0 0
20 0 ▶ push @marshals, split / /, ($this_policies_arg->{equivalent_modules} || '');
Condition0%0/2
$this_policies_arg->{'equivalent_modules'} || ''
l!l
00
MC/DC0%0/1
$this_policies_arg->{'equivalent_modules'} || ''
$this_policies_arg->{'equivalent_modules'}
Truth table0%0/2
A
A= $this_policies_arg->{'equivalent_modules'}
Aresult
11
00
21 }
22  
23 0 my @violations;
24 0 my $token_num = scalar @$tokens;
25 0 my $is_used_strict = 0;
26 0 ▶ TOP: for (my $i = 0; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
27 0 my $token = $tokens->[$i];
28 0 my $token_type = $token->{type};
29  
30 0 ▶ if ($token_type == USE_DECL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 93) 0 0 0
31 0 my $next_token = $tokens->[$i+1];
32 0 ▶ if ($next_token->{type} == DOUBLE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_token->{"type"} == 171) 0 0 0
33 0 (my $next_token_data = $next_token->{data}) =~ s/_//g;
34 0 ▶ if ($next_token_data >= EQUIVALENT_PERL_VERSION) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_token_data >= "5.011") 0 0 0
35 0 last;
36 }
37 0 next;
38 }
39  
40 0 my $used_module = '';
41 0 ▶ for ($i++; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
42 0 $token = $tokens->[$i];
43 0 my $token_type = $token->{type};
44 0 my $token_data = $token->{data};
45 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 94 or $token_type == 127 or $token_type == 126) { } 0 0 0
Condition0%0/6
$token_type == 94 or $token_type == 127 or $token_type == 126
l!l&&r!l&&!r
000
$token_type == 94 or $token_type == 127
l!l&&r!l&&!r
000
MC/DC0%0/3
$token_type == 94 or $token_type == 127 or $token_type == 126
$token_type == 94 $token_type == 127 $token_type == 126
Truth table0%0/4
A or B or C
A= $token_type == 94B= $token_type == 127C= $token_type == 126
ABCresult
1XX1
01X1
0011
0000
46 $token_type == USED_NAME ||
47 $token_type == NAMESPACE ||
48 $token_type == NAMESPACE_RESOLVER
49 ) {
50 0 $used_module .= $token_data;
51 }
52 else {
53 0 ▶ if (any {$_ eq $used_module} @marshals) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $_ eq $used_module; } , @marshals)) 0 0 0
54 0 last TOP;
55 }
56 0 next TOP;
57 }
58 }
59 }
60  
61 0 ▶ if ($token_type == PACKAGE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 128) 0 0 0
62 0 ▶ for ($i++; $i < $token_num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $token_num) 0 0 0
63 0 $token = $tokens->[$i];
64 0 ▶ if ($token->{type} == SEMI_COLON) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 106) 0 0 0
65 0 next TOP;
66 }
67 }
68 }
69  
70 push @violations, {
71 filename => $file,
72 line => $token->{line},
73 0 description => DESC,
74 explanation => EXPL,
75 policy => __PACKAGE__,
76 };
77 0 last;
78 }
79  
80 0 return \@violations;
81 }
82  
83 2 1;
84  
« Perl/Lint/Policy/RegularExpressions/ProhibitEnumeratedClasses.pm ↑ Summary Perl/Lint/Policy/TestingAndDebugging/RequireUseWarnings.pm »