|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Perl::Lint::Policy::ValuesAndExpressions::ProhibitLeadingZeros;  | 
| 
2
 | 
133
 | 
 
 | 
 
 | 
  
133
  
 | 
 
 | 
67719
 | 
 use strict;  | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
196
 | 
    | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3140
 | 
    | 
| 
3
 | 
133
 | 
 
 | 
 
 | 
  
133
  
 | 
 
 | 
406
 | 
 use warnings;  | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
160
 | 
    | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2467
 | 
    | 
| 
4
 | 
133
 | 
 
 | 
 
 | 
  
133
  
 | 
 
 | 
763
 | 
 use Perl::Lint::Constants::Type;  | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
154
 | 
    | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
56231
 | 
    | 
| 
5
 | 
133
 | 
 
 | 
 
 | 
  
133
  
 | 
 
 | 
597
 | 
 use parent "Perl::Lint::Policy";  | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
160
 | 
    | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
563
 | 
    | 
| 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 use constant {  | 
| 
8
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
50877
 | 
     DESC => q{Don't allow any leading zeros at all.  Otherwise builtins that deal with Unix permissions, e.g. chmod, don't get flagged.},  | 
| 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     EXPL => [58],  | 
| 
10
 | 
133
 | 
 
 | 
 
 | 
  
133
  
 | 
 
 | 
7203
 | 
 };  | 
| 
 
 | 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
172
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub evaluate {  | 
| 
13
 | 
13
 | 
 
 | 
 
 | 
  
13
  
 | 
  
0
  
 | 
42
 | 
     my ($class, $file, $tokens, $src, $args) = @_;  | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
15
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
19
 | 
     my $is_strict;  | 
| 
16
 | 
13
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
48
 | 
     if (my $this_policies_arg = $args->{prohibit_leading_zeros}) {  | 
| 
17
 | 
5
 | 
 
 | 
 
 | 
 
 | 
 
 | 
15
 | 
         $is_strict = $this_policies_arg->{strict};  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
20
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
     my @violations;  | 
| 
21
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
57
 | 
     for (my $i = 0; my $token = $tokens->[$i]; $i++) {  | 
| 
22
 | 
336
 | 
 
 | 
 
 | 
 
 | 
 
 | 
276
 | 
         my $token_type = $token->{type};  | 
| 
23
 | 
336
 | 
 
 | 
 
 | 
 
 | 
 
 | 
268
 | 
         my $token_data = $token->{data};  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
25
 | 
336
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
758
 | 
         if (!$is_strict && $token_type == BUILTIN_FUNC) {  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # skip the first argument of chmod()  | 
| 
27
 | 
10
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
27
 | 
             if ($token_data eq 'chmod') {  | 
| 
28
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
13
 | 
                 if ($tokens->[++$i]->{type} == LEFT_PAREN) {  | 
| 
29
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                     $i++;  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
31
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
                 next;  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # skip third argument of dbmopen()  | 
| 
35
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
             if ($token_data eq 'dbmopen') {  | 
| 
36
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
                 if ($tokens->[++$i]->{type} == LEFT_PAREN) {  | 
| 
37
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
                     $i++;  | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
40
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                 my $comma_num = 0;  | 
| 
41
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
                 for ($i++; $token = $tokens->[$i]; $i++) {  | 
| 
42
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
                     $token_type = $token->{type};  | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
44
 | 
6
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
                     if ($token_type == SEMI_COLON) {  | 
| 
45
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
                         last;  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
                     if ($token_type == COMMA) {  | 
| 
49
 | 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                         $comma_num++;  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
51
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
52
 | 
6
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
14
 | 
                     if ($comma_num == 2) {  | 
| 
53
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
                         $i++;  | 
| 
54
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
                         last;  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
57
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
                 next;  | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # skip second argument of mkdir()  | 
| 
61
 | 
4
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
15
 | 
             if ($token_data eq 'mkdir') {  | 
| 
62
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
                 if ($tokens->[++$i]->{type} == LEFT_PAREN) {  | 
| 
63
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
                     $i++;  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
66
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                 my $comma_num = 0;  | 
| 
67
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
                 for ($i++; $token = $tokens->[$i]; $i++) {  | 
| 
68
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                     $token_type = $token->{type};  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
70
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
4
 | 
                     if ($token_type == SEMI_COLON) {  | 
| 
71
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
                         last;  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
74
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
                     if ($token_type == COMMA) {  | 
| 
75
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
                         $comma_num++;  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
77
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
78
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5
 | 
                     if ($comma_num == 1) {  | 
| 
79
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2
 | 
                         $i++;  | 
| 
80
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                         last;  | 
| 
81
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
82
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
83
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
                 next;  | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
85
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # skip the first argument of umask()  | 
| 
87
 | 
2
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
7
 | 
             if ($token_data eq 'umask') {  | 
| 
88
 | 
2
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
6
 | 
                 if ($tokens->[++$i]->{type} == LEFT_PAREN) {  | 
| 
89
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1
 | 
                     $i++;  | 
| 
90
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
91
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
                 next;  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
93
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
95
 | 
326
 | 
  
100
  
 | 
  
100
  
 | 
 
 | 
 
 | 
649
 | 
         if (!$is_strict && $token_type == KEY) {  | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             # skip the fourth argument of sysopen()  | 
| 
97
 | 
3
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
8
 | 
             if ($token_data eq 'sysopen') {  | 
| 
98
 | 
3
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
9
 | 
                 if ($tokens->[++$i]->{type} == LEFT_PAREN) {  | 
| 
99
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
                     $i++;  | 
| 
100
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
102
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
                 my $comma_num = 0;  | 
| 
103
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
                 for ($i++; $token = $tokens->[$i]; $i++) {  | 
| 
104
 | 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
21
 | 
                     $token_type = $token->{type};  | 
| 
105
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
106
 | 
25
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
35
 | 
                     if ($token_type == SEMI_COLON) {  | 
| 
107
 | 
0
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
                         last;  | 
| 
108
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
109
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
110
 | 
25
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
35
 | 
                     if ($token_type == COMMA) {  | 
| 
111
 | 
9
 | 
 
 | 
 
 | 
 
 | 
 
 | 
7
 | 
                         $comma_num++;  | 
| 
112
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
113
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
114
 | 
25
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
46
 | 
                     if ($comma_num == 3) {  | 
| 
115
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
                         $i++;  | 
| 
116
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5
 | 
                         last;  | 
| 
117
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     }  | 
| 
118
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 }  | 
| 
119
 | 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
8
 | 
                 next;  | 
| 
120
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
121
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
122
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
123
 | 
323
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
644
 | 
         if ($token_type == INT) {  | 
| 
124
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
             my $int = $token_data;  | 
| 
125
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43
 | 
             $int =~ s/_//g;  | 
| 
126
 | 
37
 | 
  
100
  
 | 
  
 50
  
 | 
 
 | 
 
 | 
1855
 | 
             if ($int =~ /\A-?0/ && (eval($int) // 0) != 0) { ## no critic: to accept bin, oct and hex decimal  | 
| 
 
 | 
 
 | 
 
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
127
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 push @violations, {  | 
| 
128
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     filename => $file,  | 
| 
129
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     line     => $token->{line},  | 
| 
130
 | 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
141
 | 
                     description => DESC,  | 
| 
131
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     explanation => EXPL,  | 
| 
132
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                     policy => __PACKAGE__,  | 
| 
133
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
                 };  | 
| 
134
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
             }  | 
| 
135
 | 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
129
 | 
             next;  | 
| 
136
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
         }  | 
| 
137
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
138
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
139
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67
 | 
     return \@violations;  | 
| 
140
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
141
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
142
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
143
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    |