Perl/Lint/Policy/Subroutines/ProhibitManyArgs.pm

filter: Statementstmt 30.7% 16 / 52 Branchbran 0.0% 0 / 32 Conditioncond 0.0% 0 / 32 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 15.4% 21 / 136 CC 28 SCAR 65.4
CC
28
Cov
14%
evaluate
812.0
BEGIN
1.0
BEGIN
1.0
CRAP 689.1
« Perl/Lint/Policy/NamingConventions/ProhibitAmbiguousNames.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitSleepViaSelect.pm »
1 package Perl::Lint::Policy::Subroutines::ProhibitManyArgs;
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 => 'Too many arguments',
9 EXPL => [182],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=28 SCAR=67.0
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 ▶ my $max_arguments = $args->{prohibit_many_args}->{max_arguments} || 5;
Condition0%0/2
$args->{'prohibit_many_args'}{'max_arguments'} || 5
l!l
00
MC/DC0%0/1
$args->{'prohibit_many_args'}{'max_arguments'} || 5
$args->{'prohibit_many_args'}{'max_arguments'}
Truth table0%0/2
A
A= $args->{'prohibit_many_args'}{'max_arguments'}
Aresult
11
00
16  
17 0 my @violations;
18 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
19 0 my $token_type = $token->{type};
20  
21 0 ▶ if ($token_type == FUNCTION_DECL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token_type == 63) 0 0 0
22 0 ▶ for ($i++; $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $tokens->[$i]) 0 0 0
23 0 $token_type = $token->{type};
24 0 ▶ if ($token_type == LEFT_BRACE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token_type == 109) { } 0 0 0
elsif ($token_type == 165) { } 0 0 0
25 0 my $left_brace_num = 1;
26 0 my $num_of_vars = 0;
27 0 my $num_of_vars_per_one_line = 0;
28 0 my $last_var_token;
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  
32 0 ▶ if ($token_type == LEFT_BRACE) {
Branch: 5 branches
BranchTrueFalseTotal
if ($token_type == 109) { } 0 0 0
elsif ($token_type == 110) { } 0 0 0
elsif ($token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192 or $token_type == 195 or $token_type == 169 or $token_type == 193 or $token_type == 196) { } 0 0 0
elsif ($token_type == 65) { } 0 0 0
elsif ($token_type == 106) { } 0 0 0
33 0 $left_brace_num++;
34 }
35 elsif ($token_type == RIGHT_BRACE) {
36 0 ▶ if (--$left_brace_num <= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (--$left_brace_num <= 0) 0 0 0
37 0 ▶ if ($num_of_vars > $max_arguments) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num_of_vars > $max_arguments) 0 0 0
38 push @violations, {
39 filename => $file,
40 line => $last_var_token->{line},
41 0 description => DESC,
42 explanation => EXPL,
43 policy => __PACKAGE__,
44 };
45 }
46 0 last;
47 }
48 }
49 ▶ elsif (
Condition0%0/24
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192 or $token_type == 195 or $token_type == 169 or $token_type == 193 or $token_type == 196
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192 or $token_type == 195 or $token_type == 169 or $token_type == 193
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192 or $token_type == 195 or $token_type == 169
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192 or $token_type == 195
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191 or $token_type == 194
l!l&&r!l&&!r
000
$token_type == 166 or $token_type == 191
l!l&&r!l&&!r
000
MC/DC0%0/9
$token_type == 166 or $token_type == 191 or $token_type == 194 or $token_type == 168 or $token_type == 192 or $token_type == 195 or $token_type == 169 or $token_type == 193 or $token_type == 196
$token_type == 166 $token_type == 191 $token_type == 194 $token_type == 168 $token_type == 192 $token_type == 195 $token_type == 169 $token_type == 193 $token_type == 196
Truth table0%0/10
A or B or C or D or E or F or G or H or I
A= $token_type == 166B= $token_type == 191C= $token_type == 194D= $token_type == 168E= $token_type == 192F= $token_type == 195G= $token_type == 169H= $token_type == 193I= $token_type == 196
ABCDEFGHIresult
1XXXXXXXX1
01XXXXXXX1
001XXXXXX1
0001XXXXX1
00001XXXX1
000001XXX1
0000001XX1
00000001X1
0000000011
0000000000
50 $token_type == VAR ||
51 $token_type == LOCAL_VAR ||
52 $token_type == GLOBAL_VAR ||
53 $token_type == ARRAY_VAR ||
54 $token_type == LOCAL_ARRAY_VAR ||
55 $token_type == GLOBAL_ARRAY_VAR ||
56 $token_type == HASH_VAR ||
57 $token_type == LOCAL_HASH_VAR ||
58 $token_type == GLOBAL_HASH_VAR
59 ) {
60 0 ▶ if ($left_brace_num == 1) { # XXX
Branch: 1 branch
BranchTrueFalseTotal
if ($left_brace_num == 1) 0 0 0
61 0 $num_of_vars_per_one_line++;
62 }
63 }
64 elsif ($token_type == ASSIGN) {
65 0 my $next_token = $tokens->[$i+1];
66 0 my $next_token_type = $next_token->{type};
67 0 my $next_token_data = $next_token->{data};
68  
69 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($next_token_type == 136 or $next_token_type == 70 and $next_token_data eq "shift") 0 0 0
Condition0%0/6
$next_token_type == 136 or $next_token_type == 70 and $next_token_data eq "shift"
l!l&&r!l&&!r
000
$next_token_type == 70 and $next_token_data eq "shift"
!ll&&!rl&&r
000
MC/DC0%0/3
$next_token_type == 136 or $next_token_type == 70 and $next_token_data eq "shift"
$next_token_type == 136 $next_token_type == 70 $next_token_data eq "shift"
Truth table0%0/4
A or B and C
A= $next_token_type == 136B= $next_token_type == 70C= $next_token_data eq "shift"
ABCresult
1XX1
0111
00X0
0100
70 $next_token_type == ARGUMENT_ARRAY ||
71 ($next_token_type == BUILTIN_FUNC && $next_token_data eq 'shift')
72 ) {
73 0 $num_of_vars += $num_of_vars_per_one_line;
74 0 $last_var_token = $token;
75 }
76 }
77 elsif ($token_type == SEMI_COLON) {
78 0 $num_of_vars_per_one_line = 0;
79 }
80 }
81 }
82 elsif ($token_type == PROTOTYPE) {
83 0 (my $prototype = $token->{data}) =~ s/[ ;]//g;
84 0 $prototype =~ s/\\\[.+?\]/1/g; # XXX
85 0 ▶ if (length $prototype > $max_arguments) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $prototype > $max_arguments) 0 0 0
86 push @violations, {
87 filename => $file,
88 line => $token->{line},
89 0 description => DESC,
90 explanation => EXPL,
91 policy => __PACKAGE__,
92 };
93 0 last;
94 }
95 }
96 }
97 }
98 }
99  
100 0 return \@violations;
101 }
102  
103 2 1;
104  
« Perl/Lint/Policy/NamingConventions/ProhibitAmbiguousNames.pm ↑ Summary Perl/Lint/Policy/BuiltinFunctions/ProhibitSleepViaSelect.pm »