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