Perl/Lint/Policy/BuiltinFunctions/ProhibitSleepViaSelect.pm

filter: Statementstmt 33.3% 19 / 57 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 33 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 17.1% 25 / 146 CC 28 SCAR 65.1
CC
28
Cov
16%
evaluate
812.0
BEGIN
1.0
BEGIN
1.0
CRAP 668.9
« Perl/Lint/Policy/Subroutines/ProhibitManyArgs.pm ↑ Summary Perl/Lint/Policy/Variables/ProhibitUnusedVariables.pm »
1 package Perl::Lint::Policy::BuiltinFunctions::ProhibitSleepViaSelect;
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 Perl::Lint::Constants::Kind;
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 => '"select" used to emulate "sleep"',
10 EXPL => [168],
11 2 };
12  
13 0 ▶sub evaluate {
Subroutine evaluate: not called CC=28 SCAR=67.0
Pod undocumented
14 0 my ($class, $file, $tokens, $src, $args) = @_;
15  
16 0 my @violations;
17 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
18 0 my $token_type = $token->{type};
19 0 my $token_data = $token->{data};
20  
21 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
22 0 my $left_paren_num = 1;
23 0 my $comma_num = 0;
24 0 my $is_on_some_IO = 0;
25 0 my $last_arg = '';
26  
27 0 $token = $tokens->[++$i];
28 0 ▶ if ($token->{type} == LEFT_PAREN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'type'} == 107) { } 0 0 0
29 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
30 0 $token_type = $token->{type};
31 0 ▶ if ($token_type == LEFT_PAREN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 107) { } 0 0 0
elsif ($token_type == 108) { } 0 0 0
elsif ($token_type == 104) { } 0 0 0
32 0 $left_paren_num++;
33 }
34 elsif ($token_type == RIGHT_PAREN) {
35 0 ▶ if (--$left_paren_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$left_paren_num <= 0) 0 0 0
36 0 my $last_arg_type = $last_arg->{type};
37 0 ▶ if (!$is_on_some_IO && $comma_num == 3 && ($last_arg_type == DOUBLE || ($last_arg_type != DEFAULT && $last_arg->{kind} == KIND_TERM))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $is_on_some_IO and $comma_num == 3 and $last_arg_type == 171 || $last_arg_type != 207 && $last_arg->{"kind"} == 24) 0 0 0
Condition0%0/12
not $is_on_some_IO and $comma_num == 3 and $last_arg_type == 171 || $last_arg_type != 207 && $last_arg->{"kind"} == 24
!ll&&!rl&&r
000
not $is_on_some_IO and $comma_num == 3
!ll&&!rl&&r
000
$last_arg_type == 171 or $last_arg_type != 207 and $last_arg->{"kind"} == 24
l!l&&r!l&&!r
000
$last_arg_type != 207 and $last_arg->{"kind"} == 24
!ll&&!rl&&r
000
MC/DC0%0/5
not $is_on_some_IO and $comma_num == 3 and $last_arg_type == 171 || $last_arg_type != 207 && $last_arg->{"kind"} == 24
not $is_on_some_IO $comma_num == 3 $last_arg_type == 171 $last_arg_type != 207 $last_arg->{"kind"} == 24
Truth table0%0/6
not(A) and B and C or D and E
A= not $is_on_some_IOB= $comma_num == 3C= $last_arg_type == 171D= $last_arg_type != 207E= $last_arg->{"kind"} == 24
ABCDEresult
0XXXX0
10XXX0
1100X0
110100
111XX1
110111
38 push @violations, {
39 filename => $file,
40 line => $token->{line},
41 0 description => DESC,
42 explanation => EXPL,
43 policy => __PACKAGE__,
44 };
45 }
46 0 last;
47 }
48 }
49 elsif ($token_type == COMMA) {
50 0 $comma_num++;
51 }
52 else {
53 0 ▶ if ($comma_num < 3 && $token_type != DEFAULT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comma_num < 3 and $token_type != 207) 0 0 0
Condition0%0/3
$comma_num < 3 and $token_type != 207
!ll&&!rl&&r
000
MC/DC0%0/2
$comma_num < 3 and $token_type != 207
$comma_num < 3 $token_type != 207
Truth table0%0/3
A and B
A= $comma_num < 3B= $token_type != 207
ABresult
0X0
100
111
54 0 $is_on_some_IO = 1;
55 }
56 0 $last_arg = $token;
57 }
58 }
59 }
60 else {
61 0 ▶ for (; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
62 0 $token_type = $token->{type};
63 0 ▶ if ($token_type == SEMI_COLON) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 106) { } 0 0 0
elsif ($token_type == 104) { } 0 0 0
64 0 ▶ if (--$left_paren_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$left_paren_num <= 0) 0 0 0
65 0 my $last_arg_type = $last_arg->{type};
66 0 ▶ if (!$is_on_some_IO && $comma_num == 3 && ($last_arg_type == DOUBLE || ($last_arg_type != DEFAULT && $last_arg->{kind} == KIND_TERM))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $is_on_some_IO and $comma_num == 3 and $last_arg_type == 171 || $last_arg_type != 207 && $last_arg->{"kind"} == 24) 0 0 0
Condition0%0/12
not $is_on_some_IO and $comma_num == 3 and $last_arg_type == 171 || $last_arg_type != 207 && $last_arg->{"kind"} == 24
!ll&&!rl&&r
000
not $is_on_some_IO and $comma_num == 3
!ll&&!rl&&r
000
$last_arg_type == 171 or $last_arg_type != 207 and $last_arg->{"kind"} == 24
l!l&&r!l&&!r
000
$last_arg_type != 207 and $last_arg->{"kind"} == 24
!ll&&!rl&&r
000
MC/DC0%0/5
not $is_on_some_IO and $comma_num == 3 and $last_arg_type == 171 || $last_arg_type != 207 && $last_arg->{"kind"} == 24
not $is_on_some_IO $comma_num == 3 $last_arg_type == 171 $last_arg_type != 207 $last_arg->{"kind"} == 24
Truth table0%0/6
not(A) and B and C or D and E
A= not $is_on_some_IOB= $comma_num == 3C= $last_arg_type == 171D= $last_arg_type != 207E= $last_arg->{"kind"} == 24
ABCDEresult
0XXXX0
10XXX0
1100X0
110100
111XX1
110111
67 push @violations, {
68 filename => $file,
69 line => $token->{line},
70 0 description => DESC,
71 explanation => EXPL,
72 policy => __PACKAGE__,
73 };
74 }
75 0 last;
76 }
77 }
78 elsif ($token_type == COMMA) {
79 0 $comma_num++;
80 }
81 else {
82 0 ▶ if ($comma_num < 3 && $token_type != DEFAULT) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comma_num < 3 and $token_type != 207) 0 0 0
Condition0%0/3
$comma_num < 3 and $token_type != 207
!ll&&!rl&&r
000
MC/DC0%0/2
$comma_num < 3 and $token_type != 207
$comma_num < 3 $token_type != 207
Truth table0%0/3
A and B
A= $comma_num < 3B= $token_type != 207
ABresult
0X0
100
111
83 0 $is_on_some_IO = 1;
84 }
85 0 $last_arg = $token;
86 }
87 }
88 }
89 }
90 }
91  
92 0 return \@violations;
93 }
94  
95 2 1;
96  
« Perl/Lint/Policy/Subroutines/ProhibitManyArgs.pm ↑ Summary Perl/Lint/Policy/Variables/ProhibitUnusedVariables.pm »