Perl/Lint/Policy/InputOutput/ProhibitOneArgSelect.pm

filter: Statementstmt 36.3% 16 / 44 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 26.9% 21 / 78 CC 13 SCAR 48.8
CC
13
Cov
23%
evaluate
182.0
BEGIN
1.0
BEGIN
1.0
CRAP 131.7
« Perl/Lint/Policy/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm »
1 package Perl::Lint::Policy::InputOutput::ProhibitOneArgSelect;
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 => 'One-argument "select" used',
9 EXPL => [224],
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 'select') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 70 and $token_data eq "select") 0 0 0
Condition0%0/3
$token_type == 70 and $token_data eq "select"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token_data eq "select"
$token_type == 70 $token_data eq "select"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "select"
ABresult
0X0
100
111
21 0 $token = $tokens->[++$i];
22 0 $token_type = $token->{type};
23 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
24 0 my $args_num = 0;
25 0 my $left_paren_num = 1;
26 0 ▶ for ($i++; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
27 0 $token_type = $token->{type};
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 ▶ last if --$left_paren_num <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if --$left_paren_num <= 0 0 0 0
33 }
34 else {
35 0 $args_num++;
36 }
37 }
38 0 ▶ if ($args_num == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args_num == 1) 0 0 0
39 push @violations, {
40 filename => $file,
41 line => $token->{line},
42 0 description => DESC,
43 explanation => EXPL,
44 policy => __PACKAGE__,
45 };
46 }
47 }
48 else {
49 0 my $args_num = 0;
50 0 ▶ for (; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
51 0 $token_type = $token->{type};
52 0 ▶ if ($token_type == SEMI_COLON) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 106) { } 0 0 0
53 0 last;
54 }
55 else {
56 0 $args_num++;
57 }
58 }
59 0 ▶ if ($args_num == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args_num == 1) 0 0 0
60 push @violations, {
61 filename => $file,
62 line => $token->{line},
63 0 description => DESC,
64 explanation => EXPL,
65 policy => __PACKAGE__,
66 };
67 }
68 }
69 }
70 }
71  
72 0 return \@violations;
73 }
74  
75 2 1;
76  
« Perl/Lint/Policy/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitLvalueSubstr.pm »