1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/TestingAndDebugging/ProhibitProlongedStrictureOverride.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride;
15 use Perl::Critic::Utils qw{ :severities };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $DESC => q{Don't turn off strict for large blocks of code};
23 Readonly::Scalar my $EXPL => [ 433 ];
25 #-----------------------------------------------------------------------------
27 sub supported_parameters {
31 description => 'The maximum number of statements in a no strict block.',
32 default_string => '3',
33 behavior => 'integer',
39 sub default_severity { return $SEVERITY_HIGH }
40 sub default_themes { return qw( core pbp bugs ) }
41 sub applies_to { return 'PPI::Statement::Include' }
43 #-----------------------------------------------------------------------------
46 my ($self, $elem, $doc) = @_;
48 return if $elem->type ne 'no';
49 return if $elem->module ne 'strict';
51 my $sib = $elem->snext_sibling;
53 while ($nstatements++ <= $self->{_statements}) {
55 return if $sib->isa('PPI::Statement::Include') &&
56 $sib->type eq 'use' &&
57 $sib->module eq 'strict';
58 $sib = $sib->snext_sibling;
61 return $self->violation( $DESC, $EXPL, $elem );
66 #-----------------------------------------------------------------------------
74 Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride - Don't turn off strict for large blocks of code.
78 This Policy is part of the core L<Perl::Critic> distribution.
83 Every agrees that C<use strict> is the first step to writing maintainable code
84 in Perl. However, sometimes C<strict> is a little too strict. In those
85 cases, you can turn it off briefly with a C<no strict> directive.
87 This policy checks that C<no strict> is only in effect for a small number of
92 The default number of statements allowed per C<no strict> is three. To
93 override this number, put the following in your F<.perlcriticrc>:
95 [TestingAndDebugging::ProhibitProlongedStrictureOverride]
100 Chris Dolan <cdolan@cpan.org>
104 Copyright (C) 2006 Chris Dolan. All rights reserved.
106 This program is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself.
113 # cperl-indent-level: 4
115 # indent-tabs-mode: nil
116 # c-indentation-style: bsd
118 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :