line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package strictures; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
89121
|
use strict; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
95
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
419
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
3
|
50
|
|
3
|
|
29
|
*_PERL_LT_5_8_4 = ("$]" < 5.008004) ? sub(){1} : sub(){0}; |
8
|
|
|
|
|
|
|
# goto &UNIVERSAL::VERSION usually works on 5.8, but fails on some ARM |
9
|
|
|
|
|
|
|
# machines. Seems to always work on 5.10 though. |
10
|
3
|
50
|
|
|
|
430
|
*_CAN_GOTO_VERSION = ("$]" >= 5.010000) ? sub(){1} : sub(){0}; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '2.000006'; |
14
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @WARNING_CATEGORIES = grep { exists $warnings::Offsets{$_} } qw( |
17
|
|
|
|
|
|
|
closure |
18
|
|
|
|
|
|
|
chmod |
19
|
|
|
|
|
|
|
deprecated |
20
|
|
|
|
|
|
|
exiting |
21
|
|
|
|
|
|
|
experimental |
22
|
|
|
|
|
|
|
experimental::alpha_assertions |
23
|
|
|
|
|
|
|
experimental::autoderef |
24
|
|
|
|
|
|
|
experimental::bitwise |
25
|
|
|
|
|
|
|
experimental::const_attr |
26
|
|
|
|
|
|
|
experimental::declared_refs |
27
|
|
|
|
|
|
|
experimental::lexical_subs |
28
|
|
|
|
|
|
|
experimental::lexical_topic |
29
|
|
|
|
|
|
|
experimental::postderef |
30
|
|
|
|
|
|
|
experimental::private_use |
31
|
|
|
|
|
|
|
experimental::re_strict |
32
|
|
|
|
|
|
|
experimental::refaliasing |
33
|
|
|
|
|
|
|
experimental::regex_sets |
34
|
|
|
|
|
|
|
experimental::script_run |
35
|
|
|
|
|
|
|
experimental::signatures |
36
|
|
|
|
|
|
|
experimental::smartmatch |
37
|
|
|
|
|
|
|
experimental::win32_perlio |
38
|
|
|
|
|
|
|
glob |
39
|
|
|
|
|
|
|
imprecision |
40
|
|
|
|
|
|
|
io |
41
|
|
|
|
|
|
|
closed |
42
|
|
|
|
|
|
|
exec |
43
|
|
|
|
|
|
|
layer |
44
|
|
|
|
|
|
|
newline |
45
|
|
|
|
|
|
|
pipe |
46
|
|
|
|
|
|
|
syscalls |
47
|
|
|
|
|
|
|
unopened |
48
|
|
|
|
|
|
|
locale |
49
|
|
|
|
|
|
|
misc |
50
|
|
|
|
|
|
|
missing |
51
|
|
|
|
|
|
|
numeric |
52
|
|
|
|
|
|
|
once |
53
|
|
|
|
|
|
|
overflow |
54
|
|
|
|
|
|
|
pack |
55
|
|
|
|
|
|
|
portable |
56
|
|
|
|
|
|
|
recursion |
57
|
|
|
|
|
|
|
redefine |
58
|
|
|
|
|
|
|
redundant |
59
|
|
|
|
|
|
|
regexp |
60
|
|
|
|
|
|
|
severe |
61
|
|
|
|
|
|
|
debugging |
62
|
|
|
|
|
|
|
inplace |
63
|
|
|
|
|
|
|
internal |
64
|
|
|
|
|
|
|
malloc |
65
|
|
|
|
|
|
|
shadow |
66
|
|
|
|
|
|
|
signal |
67
|
|
|
|
|
|
|
substr |
68
|
|
|
|
|
|
|
syntax |
69
|
|
|
|
|
|
|
ambiguous |
70
|
|
|
|
|
|
|
bareword |
71
|
|
|
|
|
|
|
digit |
72
|
|
|
|
|
|
|
illegalproto |
73
|
|
|
|
|
|
|
parenthesis |
74
|
|
|
|
|
|
|
precedence |
75
|
|
|
|
|
|
|
printf |
76
|
|
|
|
|
|
|
prototype |
77
|
|
|
|
|
|
|
qw |
78
|
|
|
|
|
|
|
reserved |
79
|
|
|
|
|
|
|
semicolon |
80
|
|
|
|
|
|
|
taint |
81
|
|
|
|
|
|
|
threads |
82
|
|
|
|
|
|
|
uninitialized |
83
|
|
|
|
|
|
|
umask |
84
|
|
|
|
|
|
|
unpack |
85
|
|
|
|
|
|
|
untie |
86
|
|
|
|
|
|
|
utf8 |
87
|
|
|
|
|
|
|
non_unicode |
88
|
|
|
|
|
|
|
nonchar |
89
|
|
|
|
|
|
|
surrogate |
90
|
|
|
|
|
|
|
void |
91
|
|
|
|
|
|
|
void_unusual |
92
|
|
|
|
|
|
|
y2k |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub VERSION { |
96
|
|
|
|
|
|
|
{ |
97
|
3
|
|
|
3
|
1
|
21
|
no warnings; |
|
3
|
|
|
33
|
|
6
|
|
|
3
|
|
|
|
|
3412
|
|
|
33
|
|
|
|
|
31973
|
|
98
|
33
|
|
|
|
|
63
|
local $@; |
99
|
33
|
100
|
100
|
|
|
117
|
if (defined $_[1] && eval { &UNIVERSAL::VERSION; 1}) { |
|
32
|
|
|
|
|
364
|
|
|
31
|
|
|
|
|
182
|
|
100
|
31
|
|
|
|
|
92
|
$^H |= 0x20000 |
101
|
|
|
|
|
|
|
unless _PERL_LT_5_8_4; |
102
|
31
|
|
|
|
|
161
|
$^H{strictures_enable} = int $_[1]; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
33
|
|
|
|
|
312
|
_CAN_GOTO_VERSION ? goto &UNIVERSAL::VERSION : &UNIVERSAL::VERSION; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
our %extra_load_states; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
our $Smells_Like_VCS; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub import { |
113
|
34
|
|
|
34
|
|
1518
|
my $class = shift; |
114
|
34
|
100
|
|
|
|
103
|
my %opts = @_ == 1 ? %{$_[0]} : @_; |
|
2
|
|
|
|
|
9
|
|
115
|
34
|
100
|
|
|
|
81
|
if (!exists $opts{version}) { |
116
|
|
|
|
|
|
|
$opts{version} |
117
|
|
|
|
|
|
|
= exists $^H{strictures_enable} ? delete $^H{strictures_enable} |
118
|
32
|
100
|
|
|
|
136
|
: int $VERSION; |
119
|
|
|
|
|
|
|
} |
120
|
34
|
|
|
|
|
129
|
$opts{file} = (caller)[1]; |
121
|
34
|
|
|
|
|
88
|
$class->_enable(\%opts); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub _enable { |
125
|
34
|
|
|
34
|
|
84
|
my ($class, $opts) = @_; |
126
|
34
|
|
|
|
|
87
|
my $version = $opts->{version}; |
127
|
34
|
100
|
|
|
|
80
|
$version = 'undef' |
128
|
|
|
|
|
|
|
if !defined $version; |
129
|
34
|
|
|
|
|
73
|
my $method = "_enable_$version"; |
130
|
34
|
100
|
|
|
|
175
|
if (!$class->can($method)) { |
131
|
2
|
|
|
|
|
10
|
require Carp; |
132
|
2
|
|
|
|
|
305
|
Carp::croak("Major version specified as $version - not supported!"); |
133
|
|
|
|
|
|
|
} |
134
|
32
|
|
|
|
|
83
|
$class->$method($opts); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub _enable_1 { |
138
|
15
|
|
|
15
|
|
27
|
my ($class, $opts) = @_; |
139
|
15
|
|
|
|
|
89
|
strict->import; |
140
|
15
|
|
|
|
|
248
|
warnings->import(FATAL => 'all'); |
141
|
|
|
|
|
|
|
|
142
|
15
|
100
|
|
|
|
48
|
if (_want_extra($opts->{file})) { |
143
|
8
|
|
|
|
|
25
|
_load_extras(qw(indirect multidimensional bareword::filehandles)); |
144
|
|
|
|
|
|
|
indirect->unimport(':fatal') |
145
|
8
|
100
|
|
|
|
35
|
if $extra_load_states{indirect}; |
146
|
|
|
|
|
|
|
multidimensional->unimport |
147
|
8
|
100
|
|
|
|
50
|
if $extra_load_states{multidimensional}; |
148
|
|
|
|
|
|
|
bareword::filehandles->unimport |
149
|
8
|
100
|
|
|
|
124
|
if $extra_load_states{'bareword::filehandles'}; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
our @V2_NONFATAL = grep { exists $warnings::Offsets{$_} } ( |
154
|
|
|
|
|
|
|
'exec', # not safe to catch |
155
|
|
|
|
|
|
|
'recursion', # will be caught by other mechanisms |
156
|
|
|
|
|
|
|
'internal', # not safe to catch |
157
|
|
|
|
|
|
|
'malloc', # not safe to catch |
158
|
|
|
|
|
|
|
'newline', # stat on nonexistent file with a newline in it |
159
|
|
|
|
|
|
|
'experimental', # no reason for these to be fatal |
160
|
|
|
|
|
|
|
'deprecated', # unfortunately can't make these fatal |
161
|
|
|
|
|
|
|
'portable', # everything worked fine here, just may not elsewhere |
162
|
|
|
|
|
|
|
); |
163
|
|
|
|
|
|
|
our @V2_DISABLE = grep { exists $warnings::Offsets{$_} } ( |
164
|
|
|
|
|
|
|
'once' # triggers inconsistently, can't be fatalized |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub _enable_2 { |
168
|
17
|
|
|
17
|
|
32
|
my ($class, $opts) = @_; |
169
|
17
|
|
|
|
|
77
|
strict->import; |
170
|
17
|
|
|
|
|
160
|
warnings->import; |
171
|
17
|
|
|
|
|
1040
|
warnings->import(FATAL => @WARNING_CATEGORIES); |
172
|
17
|
|
|
|
|
275
|
warnings->unimport(FATAL => @V2_NONFATAL); |
173
|
17
|
|
|
|
|
176
|
warnings->import(@V2_NONFATAL); |
174
|
17
|
|
|
|
|
106
|
warnings->unimport(@V2_DISABLE); |
175
|
|
|
|
|
|
|
|
176
|
17
|
100
|
|
|
|
38
|
if (_want_extra($opts->{file})) { |
177
|
9
|
|
|
|
|
29
|
_load_extras(qw(indirect multidimensional bareword::filehandles)); |
178
|
|
|
|
|
|
|
indirect->unimport(':fatal') |
179
|
9
|
100
|
|
|
|
39
|
if $extra_load_states{indirect}; |
180
|
|
|
|
|
|
|
multidimensional->unimport |
181
|
9
|
100
|
|
|
|
44
|
if $extra_load_states{multidimensional}; |
182
|
|
|
|
|
|
|
bareword::filehandles->unimport |
183
|
9
|
100
|
|
|
|
136
|
if $extra_load_states{'bareword::filehandles'}; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub _want_extra_env { |
188
|
32
|
100
|
|
32
|
|
88
|
if (exists $ENV{PERL_STRICTURES_EXTRA}) { |
189
|
8
|
|
|
|
|
12
|
if (_PERL_LT_5_8_4 and $ENV{PERL_STRICTURES_EXTRA}) { |
190
|
|
|
|
|
|
|
die 'PERL_STRICTURES_EXTRA checks are not available on perls older' |
191
|
|
|
|
|
|
|
. "than 5.8.4: please unset \$ENV{PERL_STRICTURES_EXTRA}\n"; |
192
|
|
|
|
|
|
|
} |
193
|
8
|
100
|
|
|
|
34
|
return $ENV{PERL_STRICTURES_EXTRA} ? 1 : 0; |
194
|
|
|
|
|
|
|
} |
195
|
24
|
|
|
|
|
38
|
return undef; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub _want_extra { |
199
|
32
|
|
|
32
|
|
55
|
my $file = shift; |
200
|
32
|
|
|
|
|
56
|
my $want_env = _want_extra_env(); |
201
|
32
|
100
|
|
|
|
212
|
return $want_env |
202
|
|
|
|
|
|
|
if defined $want_env; |
203
|
|
|
|
|
|
|
return ( |
204
|
24
|
|
66
|
|
|
477
|
!_PERL_LT_5_8_4 |
205
|
|
|
|
|
|
|
and $file =~ /^(?:t|xt|lib|blib)[\\\/]/ |
206
|
|
|
|
|
|
|
and defined $Smells_Like_VCS ? $Smells_Like_VCS |
207
|
|
|
|
|
|
|
: ( $Smells_Like_VCS = !!( |
208
|
|
|
|
|
|
|
-e '.git' || -e '.svn' || -e '.hg' || -e '.bzr' |
209
|
|
|
|
|
|
|
|| (-e '../../dist.ini' |
210
|
|
|
|
|
|
|
&& (-e '../../.git' || -e '../../.svn' || -e '../../.hg' || -e '../../.bzr' )) |
211
|
|
|
|
|
|
|
)) |
212
|
|
|
|
|
|
|
); |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub _load_extras { |
216
|
17
|
|
|
17
|
|
45
|
my @extras = @_; |
217
|
17
|
|
|
|
|
24
|
my @failed; |
218
|
17
|
|
|
|
|
33
|
foreach my $mod (@extras) { |
219
|
|
|
|
|
|
|
next |
220
|
51
|
100
|
|
|
|
141
|
if exists $extra_load_states{$mod}; |
221
|
|
|
|
|
|
|
|
222
|
12
|
100
|
|
|
|
724
|
$extra_load_states{$mod} = eval "require $mod; 1;" or do { |
223
|
9
|
|
|
|
|
128
|
push @failed, $mod; |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
#work around 5.8 require bug |
226
|
9
|
|
|
|
|
33
|
(my $file = $mod) =~ s|::|/|g; |
227
|
9
|
|
|
|
|
42
|
delete $INC{"${file}.pm"}; |
228
|
|
|
|
|
|
|
}; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
17
|
100
|
|
|
|
49
|
if (@failed) { |
232
|
3
|
|
|
|
|
10
|
my $failed = join ' ', @failed; |
233
|
3
|
|
|
|
|
7
|
my $extras = join ' ', @extras; |
234
|
3
|
|
|
|
|
37
|
print STDERR <
|
235
|
|
|
|
|
|
|
strictures.pm extra testing active but couldn't load all modules. Missing were: |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
$failed |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Extra testing is auto-enabled in checkouts only, so if you're the author |
240
|
|
|
|
|
|
|
of a strictures-using module you need to run: |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
cpan $extras |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
but these modules are not required by your users. |
245
|
|
|
|
|
|
|
EOE |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
1; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
__END__ |