Perl/Lint/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm

filter: Statementstmt 39.0% 16 / 41 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 28.0% 21 / 75 CC 13 SCAR 48.8
CC
13
Cov
24%
evaluate
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 131.7
« Perl/Lint/Policy/InputOutput/ProhibitOneArgSelect.pm ↑ Summary Perl/Lint/Policy/Modules/RequireEndWithOne.pm »
1 package Perl::Lint::Policy::BuiltinFunctions::ProhibitLvalueSubstr;
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::Type;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent "Perl::Lint::Policy";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 DESC => 'Lvalue form of "substr" used',
9 EXPL => [165],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=13 SCAR=52.0
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
17 0 my $token_type = $token->{type};
18 0 my $token_data = $token->{data};
19  
20 0 ▶ if ($token_type == BUILTIN_FUNC && $token_data eq 'substr') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 70 and $token_data eq 'substr') { } 0 0 0
elsif ($token_type == 93) { } 0 0 0
Condition0%0/3
$token_type == 70 and $token_data eq "substr"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token_data eq "substr"
$token_type == 70 $token_data eq "substr"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "substr"
ABresult
0X0
100
111
21 0 $token = $tokens->[++$i];
22 0 ▶ if ($token->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 107) 0 0 0
23 0 my $left_paren_num = 1;
24 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
25 0 $token = $tokens->[++$i];
26 0 $token_type = $token->{type};
27  
28 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
29 0 $left_paren_num++;
30 }
31 elsif ($token_type == RIGHT_PAREN) {
32 0 ▶ if (--$left_paren_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$left_paren_num <= 0) 0 0 0
33 0 my $next_token = $tokens->[++$i];
34 0 ▶ if ($next_token->{type} == ASSIGN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next_token->{"type"} == 65) 0 0 0
35 push @violations, {
36 filename => $file,
37 line => $token->{line},
38 0 description => DESC,
39 explanation => EXPL,
40 policy => __PACKAGE__,
41 };
42 }
43 0 last;
44 }
45 }
46 }
47 }
48 }
49 elsif ($token_type == USE_DECL) {
50 0 $token = $tokens->[++$i];
51 0 ▶ if ($token->{type} == DOUBLE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"type"} == 171) 0 0 0
52 0 ($token_data = $token->{data}) =~ s/_//g;
53 0 ▶ if ($token_data <= 5.004) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_data <= "5.004") 0 0 0
54 0 return [];
55 }
56 }
57 }
58 }
59  
60 0 return \@violations;
61 }
62  
63 2 1;
64  
« Perl/Lint/Policy/InputOutput/ProhibitOneArgSelect.pm ↑ Summary Perl/Lint/Policy/Modules/RequireEndWithOne.pm »