Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Policy / TestingAndDebugging / ProhibitProlongedStrictureOverride.pm
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) $
4 #   $Author: clonezone $
5 # $Revision: 2489 $
6 ##############################################################################
7
8 package Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :severities };
16 use base 'Perl::Critic::Policy';
17
18 our $VERSION = '1.088';
19
20 #-----------------------------------------------------------------------------
21
22 Readonly::Scalar my $DESC => q{Don't turn off strict for large blocks of code};
23 Readonly::Scalar my $EXPL => [ 433 ];
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters {
28     return (
29         {
30             name            => 'statements',
31             description     => 'The maximum number of statements in a no strict block.',
32             default_string  => '3',
33             behavior        => 'integer',
34             integer_minimum => 1,
35         },
36     );
37 }
38
39 sub default_severity { return $SEVERITY_HIGH            }
40 sub default_themes   { return qw( core pbp bugs )       }
41 sub applies_to       { return 'PPI::Statement::Include' }
42
43 #-----------------------------------------------------------------------------
44
45 sub violates {
46     my ($self, $elem, $doc) = @_;
47
48     return if $elem->type ne 'no';
49     return if $elem->module ne 'strict';
50
51     my $sib = $elem->snext_sibling;
52     my $nstatements = 0;
53     while ($nstatements++ <= $self->{_statements}) {
54         return if !$sib;
55         return if $sib->isa('PPI::Statement::Include') &&
56             $sib->type eq 'use' &&
57             $sib->module eq 'strict';
58        $sib = $sib->snext_sibling;
59     }
60
61     return $self->violation( $DESC, $EXPL, $elem );
62 }
63
64 1;
65
66 #-----------------------------------------------------------------------------
67
68 __END__
69
70 =pod
71
72 =head1 NAME
73
74 Perl::Critic::Policy::TestingAndDebugging::ProhibitProlongedStrictureOverride - Don't turn off strict for large blocks of code.
75
76 =head1 AFFILIATION
77
78 This Policy is part of the core L<Perl::Critic> distribution.
79
80
81 =head1 DESCRIPTION
82
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.
86
87 This policy checks that C<no strict> is only in effect for a small number of
88 statements.
89
90 =head1 CONFIGURATION
91
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>:
94
95  [TestingAndDebugging::ProhibitProlongedStrictureOverride]
96  statements = 5
97
98 =head1 AUTHOR
99
100 Chris Dolan <cdolan@cpan.org>
101
102 =head1 COPYRIGHT
103
104 Copyright (C) 2006 Chris Dolan.  All rights reserved.
105
106 This program is free software; you can redistribute it and/or modify
107 it under the same terms as Perl itself.
108
109 =cut
110
111 # Local Variables:
112 #   mode: cperl
113 #   cperl-indent-level: 4
114 #   fill-column: 78
115 #   indent-tabs-mode: nil
116 #   c-indentation-style: bsd
117 # End:
118 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :