line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
26590
|
use 5.010001; |
|
40
|
|
|
|
|
178
|
|
4
|
40
|
|
|
40
|
|
297
|
use strict; |
|
40
|
|
|
|
|
111
|
|
|
40
|
|
|
|
|
853
|
|
5
|
40
|
|
|
40
|
|
252
|
use warnings; |
|
40
|
|
|
|
|
132
|
|
|
40
|
|
|
|
|
953
|
|
6
|
40
|
|
|
40
|
|
239
|
use Readonly; |
|
40
|
|
|
|
|
123
|
|
|
40
|
|
|
|
|
1902
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
275
|
use Perl::Critic::Utils qw{ :severities }; |
|
40
|
|
|
|
|
112
|
|
|
40
|
|
|
|
|
1922
|
|
9
|
40
|
|
|
40
|
|
4734
|
use parent 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
121
|
|
|
40
|
|
|
|
|
237
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.146'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Don't turn off strict for large blocks of code}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => [ 433 ]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub supported_parameters { |
21
|
|
|
|
|
|
|
return ( |
22
|
|
|
|
|
|
|
{ |
23
|
96
|
|
|
96
|
0
|
2274
|
name => 'statements', |
24
|
|
|
|
|
|
|
description => 'The maximum number of statements in a no strict block.', |
25
|
|
|
|
|
|
|
default_string => '3', |
26
|
|
|
|
|
|
|
behavior => 'integer', |
27
|
|
|
|
|
|
|
integer_minimum => 1, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
76
|
|
|
76
|
1
|
354
|
sub default_severity { return $SEVERITY_HIGH } |
33
|
92
|
|
|
92
|
1
|
423
|
sub default_themes { return qw( core pbp bugs certrec ) } |
34
|
38
|
|
|
38
|
1
|
167
|
sub applies_to { return 'PPI::Statement::Include' } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub violates { |
39
|
73
|
|
|
73
|
1
|
235
|
my ($self, $elem, $doc) = @_; |
40
|
|
|
|
|
|
|
|
41
|
73
|
100
|
|
|
|
223
|
return if $elem->type ne 'no'; |
42
|
6
|
50
|
|
|
|
134
|
return if $elem->module ne 'strict'; |
43
|
|
|
|
|
|
|
|
44
|
6
|
|
|
|
|
175
|
my $sib = $elem->snext_sibling; |
45
|
6
|
|
|
|
|
245
|
my $nstatements = 0; |
46
|
6
|
|
|
|
|
35
|
while ($nstatements++ <= $self->{_statements}) { |
47
|
21
|
100
|
|
|
|
491
|
return if !$sib; |
48
|
17
|
0
|
33
|
|
|
71
|
return if $sib->isa('PPI::Statement::Include') && |
|
|
|
33
|
|
|
|
|
49
|
|
|
|
|
|
|
$sib->type eq 'use' && |
50
|
|
|
|
|
|
|
$sib->module eq 'strict'; |
51
|
17
|
|
|
|
|
47
|
$sib = $sib->snext_sibling; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
80
|
return $self->violation( $DESC, $EXPL, $elem ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride - Don't turn off strict for large blocks of code. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AFFILIATION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
73
|
|
|
|
|
|
|
distribution. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Every agrees that C<use strict> is the first step to writing |
79
|
|
|
|
|
|
|
maintainable code in Perl. However, sometimes C<strict> is a little |
80
|
|
|
|
|
|
|
too strict. In those cases, you can turn it off briefly with a C<no |
81
|
|
|
|
|
|
|
strict> directive. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This policy checks that C<no strict> is only in effect for a small |
84
|
|
|
|
|
|
|
number of statements. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 CONFIGURATION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
The default number of statements allowed per C<no strict> is three. |
90
|
|
|
|
|
|
|
To override this number, put the following in your F<.perlcriticrc>: |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
[TestingAndDebugging::ProhibitProlongedStrictureOverride] |
93
|
|
|
|
|
|
|
statements = 5 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHOR |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Chris Dolan <cdolan@cpan.org> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Copyright (c) 2006-2011 Chris Dolan. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
106
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# Local Variables: |
111
|
|
|
|
|
|
|
# mode: cperl |
112
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
113
|
|
|
|
|
|
|
# fill-column: 78 |
114
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
115
|
|
|
|
|
|
|
# c-indentation-style: bsd |
116
|
|
|
|
|
|
|
# End: |
117
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |