line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
28038
|
use 5.010001; |
|
40
|
|
|
|
|
195
|
|
4
|
40
|
|
|
40
|
|
264
|
use strict; |
|
40
|
|
|
|
|
161
|
|
|
40
|
|
|
|
|
913
|
|
5
|
40
|
|
|
40
|
|
220
|
use warnings; |
|
40
|
|
|
|
|
136
|
|
|
40
|
|
|
|
|
1137
|
|
6
|
40
|
|
|
40
|
|
581
|
use Readonly; |
|
40
|
|
|
|
|
126
|
|
|
40
|
|
|
|
|
2789
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
338
|
use Perl::Critic::Utils qw<:severities :booleans>; |
|
40
|
|
|
|
|
670
|
|
|
40
|
|
|
|
|
2112
|
|
9
|
40
|
|
|
40
|
|
6758
|
use parent 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
116
|
|
|
40
|
|
|
|
|
309
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.146'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Unrestricted '## no critic' annotation}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Only disable the Policies you really need to disable}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
93
|
|
|
93
|
0
|
1625
|
sub supported_parameters { return () } |
21
|
87
|
|
|
87
|
1
|
406
|
sub default_severity { return $SEVERITY_MEDIUM } |
22
|
74
|
|
|
74
|
1
|
350
|
sub default_themes { return qw( core maintenance ) } |
23
|
5
|
|
|
5
|
1
|
21
|
sub applies_to { return 'PPI::Document' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub violates { |
28
|
5
|
|
|
5
|
1
|
17
|
my ( $self, $doc, undef ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# If for some reason $doc is not a P::C::Document, then all bets are off |
31
|
5
|
50
|
|
|
|
24
|
return if not $doc->isa('Perl::Critic::Document'); |
32
|
|
|
|
|
|
|
|
33
|
5
|
|
|
|
|
14
|
my @violations = (); |
34
|
5
|
|
|
|
|
35
|
for my $annotation ($doc->annotations()) { |
35
|
25
|
100
|
|
|
|
65
|
if ($annotation->disables_all_policies()) { |
36
|
13
|
|
|
|
|
35
|
my $elem = $annotation->element(); |
37
|
13
|
|
|
|
|
64
|
push @violations, $self->violation($DESC, $EXPL, $elem); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
26
|
return @violations; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=for stopwords syntaxes |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic - Forbid a bare C<## no critic> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 AFFILIATION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
64
|
|
|
|
|
|
|
distribution. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
A bare C<## no critic> annotation will disable B<all> the active Policies. This |
70
|
|
|
|
|
|
|
creates holes for other, unintended violations to appear in your code. It is |
71
|
|
|
|
|
|
|
better to disable B<only> the particular Policies that you need to get around. |
72
|
|
|
|
|
|
|
By putting Policy names in a comma-separated list after the C<## no critic> |
73
|
|
|
|
|
|
|
annotation, then it will only disable the named Policies. Policy names are |
74
|
|
|
|
|
|
|
matched as regular expressions, so you can use shortened Policy names, or |
75
|
|
|
|
|
|
|
patterns that match several Policies. This Policy generates a violation any |
76
|
|
|
|
|
|
|
time that an unrestricted C<## no critic> annotation appears. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
## no critic # not ok |
79
|
|
|
|
|
|
|
## no critic '' # not ok |
80
|
|
|
|
|
|
|
## no critic () # not ok |
81
|
|
|
|
|
|
|
## no critic qw() # not ok |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
## no critic (Policy1, Policy2) # ok |
84
|
|
|
|
|
|
|
## no critic (Policy1 Policy2) # ok (can use spaces to separate) |
85
|
|
|
|
|
|
|
## no critic qw(Policy1 Policy2) # ok (the preferred style) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NOTE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Unfortunately, L<Perl::Critic|Perl::Critic> is very sloppy about |
91
|
|
|
|
|
|
|
parsing the Policy names that appear after a C<##no critic> |
92
|
|
|
|
|
|
|
annotation. For example, you might be using one of these |
93
|
|
|
|
|
|
|
broken syntaxes... |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
## no critic Policy1 Policy2 |
96
|
|
|
|
|
|
|
## no critic 'Policy1, Policy2' |
97
|
|
|
|
|
|
|
## no critic "Policy1, Policy2" |
98
|
|
|
|
|
|
|
## no critic "Policy1", "Policy2" |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
In all of these cases, Perl::Critic will silently disable B<all> Policies, |
101
|
|
|
|
|
|
|
rather than just the ones you requested. But if you use the |
102
|
|
|
|
|
|
|
C<ProhibitUnrestrictedNoCritic> Policy, all of these will generate |
103
|
|
|
|
|
|
|
violations. That way, you can track them down and correct them to use |
104
|
|
|
|
|
|
|
the correct syntax, as shown above in the L<"DESCRIPTION">. If you've |
105
|
|
|
|
|
|
|
been using the syntax that is shown throughout the Perl::Critic |
106
|
|
|
|
|
|
|
documentation for the last few years, then you should be fine. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 CONFIGURATION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright (c) 2008-2011 Imaginative Software Systems. All rights reserved. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
124
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
125
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
############################################################################### |
130
|
|
|
|
|
|
|
# Local Variables: |
131
|
|
|
|
|
|
|
# mode: cperl |
132
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
133
|
|
|
|
|
|
|
# fill-column: 78 |
134
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
135
|
|
|
|
|
|
|
# c-indentation-style: bsd |
136
|
|
|
|
|
|
|
# End: |
137
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |