Login
Woops, I left a naked subroutine out there.
[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
18our $VERSION = '1.093_01';
19
20#-----------------------------------------------------------------------------
21
22Readonly::Scalar my $DESC => q{Unrestriced '## no critic' pseudo-pragma};
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 ) }
30sub applies_to { return 'PPI::Token::Comment' }
05e2d404
JRT
31
32#-----------------------------------------------------------------------------
dd352433 33# TODO: Consolidate these regexen with those used in Critic.pm
05e2d404
JRT
34
35sub violates {
36 my ( $self, $elem, undef ) = @_;
2201928f
JRT
37 $elem =~ m{\A \#\# \s* no \s+ critic \s* (.*) \z}smx
38 or return;
05e2d404 39
2201928f 40 if ($1 !~ m{\A (?: qw)? \s* [("'] \s* \w+ }smx ) {
05e2d404
JRT
41 return $self->violation( $DESC, $EXPL, $elem );
42 }
43
44 return; # ok!
45}
46
47
481;
49
50__END__
51
52#-----------------------------------------------------------------------------
53
54=pod
55
56=head1 NAME
57
58Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic - Forbid a bare C<## no critic>
59
05e2d404
JRT
60=head1 AFFILIATION
61
62This Policy is part of the core L<Perl::Critic|Perl::Critic>
63distribution.
64
05e2d404
JRT
65=head1 DESCRIPTION
66
67A bare C<## no critic> marker will disable B<all> the active Policies.
68This creates holes for other, unintended violations to appear in your code. It is
69better to disable B<only> the particular Policies that you need to get around.
2201928f
JRT
70By putting Policy names in a comma-separated list after the C<## no critic> marker,
71then it will only disable the named Policies. Policy names are matched as regular
72expressions, so you can use shortened Policy names, or patterns that match several
73Policies. This Policy generates a violation any time that an unrestricted
74C<## no critic> marker appears.
75
76 ## no critic # not ok
77 ## no critic '' # not ok
78 ## no critic () # not ok
79 ## no critic qw() # not ok
80
81 ## no critic Policy1, Policy2 # ok
82 ## no critic 'Policy1, Policy2' # ok
83 ## no critic (Policy1, Policy2) # ok
84 ## no critic qw(Policy1, Policy2) # ok (the preferred style)
05e2d404
JRT
85
86=head1 CONFIGURATION
87
88This Policy is not configurable except for the standard options.
89
05e2d404
JRT
90=head1 AUTHOR
91
92Jeffrey Ryan Thalhammer <thaljef@cpan.org>
93
94=head1 COPYRIGHT
95
96Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer. All rights reserved.
97
98This program is free software; you can redistribute it and/or modify
99it under the same terms as Perl itself. The full text of this license
100can be found in the LICENSE file included with this module.
101
102=cut
103
104# Local Variables:
105# mode: cperl
106# cperl-indent-level: 4
107# fill-column: 78
108# indent-tabs-mode: nil
109# c-indentation-style: bsd
110# End:
111# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :