Commit | Line | Data |
---|---|---|
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 | ||
8 | package Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic; | |
9 | ||
10 | use 5.006001; | |
11 | use strict; | |
12 | use warnings; | |
13 | use Readonly; | |
14 | ||
15 | use Perl::Critic::Utils qw<:severities :booleans>; | |
16 | use base 'Perl::Critic::Policy'; | |
17 | ||
18 | our $VERSION = '1.093_01'; | |
19 | ||
20 | #----------------------------------------------------------------------------- | |
21 | ||
22 | Readonly::Scalar my $DESC => q{Unrestriced '## no critic' pseudo-pragma}; | |
23 | Readonly::Scalar my $EXPL => q{Only disable the Policies you really need to disable}; | |
24 | ||
25 | #----------------------------------------------------------------------------- | |
26 | ||
27 | sub supported_parameters { return () } | |
28 | sub default_severity { return $SEVERITY_MEDIUM } | |
29 | sub default_themes { return qw( core maintenance ) } | |
30 | sub applies_to { return 'PPI::Token::Comment' } | |
31 | sub can_be_disabled { return $FALSE } | |
32 | ||
33 | #----------------------------------------------------------------------------- | |
34 | ||
35 | sub violates { | |
36 | my ( $self, $elem, undef ) = @_; | |
37 | return if $elem !~ m{\A \#\# \s+ no \s+ critic \b}smx; | |
38 | ||
39 | if ($elem !~ m{\A \#\# \s+ no \s+ critic \s* (?: qw)? \( .+ \)}smx ) { | |
40 | return $self->violation( $DESC, $EXPL, $elem ); | |
41 | } | |
42 | ||
43 | return; # ok! | |
44 | } | |
45 | ||
46 | ||
47 | 1; | |
48 | ||
49 | __END__ | |
50 | ||
51 | #----------------------------------------------------------------------------- | |
52 | ||
53 | =pod | |
54 | ||
55 | =head1 NAME | |
56 | ||
57 | Perl::Critic::Policy::Miscellanea::ProhibitUnrestrictedNoCritic - Forbid a bare C<## no critic> | |
58 | ||
59 | ||
60 | =head1 AFFILIATION | |
61 | ||
62 | This Policy is part of the core L<Perl::Critic|Perl::Critic> | |
63 | distribution. | |
64 | ||
65 | ||
66 | =head1 DESCRIPTION | |
67 | ||
68 | A bare C<## no critic> marker will disable B<all> the active Policies. | |
69 | This creates holes for other, unintended violations to appear in your code. It is | |
70 | better to disable B<only> the particular Policies that you need to get around. | |
71 | By putting Policy names in parenthsis after the C<## no critic> marker, then | |
72 | it will only disable the named Policies. Policy names are matched as regular | |
73 | expressions, so you can use shortened Policy names, or patterns that match | |
74 | several Policies. This Policy generates a violation any time that an | |
75 | unrestricted C<## no critic> marker appears. | |
76 | ||
77 | ## no critic # not ok | |
78 | ## no critic () # not ok | |
79 | ## no critic (SomePolicyNames) # ok | |
80 | ||
81 | =head1 CONFIGURATION | |
82 | ||
83 | This Policy is not configurable except for the standard options. | |
84 | ||
85 | ||
86 | =head1 AUTHOR | |
87 | ||
88 | Jeffrey Ryan Thalhammer <thaljef@cpan.org> | |
89 | ||
90 | =head1 COPYRIGHT | |
91 | ||
92 | Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer. All rights reserved. | |
93 | ||
94 | This program is free software; you can redistribute it and/or modify | |
95 | it under the same terms as Perl itself. The full text of this license | |
96 | can be found in the LICENSE file included with this module. | |
97 | ||
98 | =cut | |
99 | ||
100 | # Local Variables: | |
101 | # mode: cperl | |
102 | # cperl-indent-level: 4 | |
103 | # fill-column: 78 | |
104 | # indent-tabs-mode: nil | |
105 | # c-indentation-style: bsd | |
106 | # End: | |
107 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |