Build all packages removed dependencies of libtest-exception-perl libtest-warn-perl...
[dh-make-perl] / dev / i386 / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Policy / Modules / ProhibitMultiplePackages.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/Modules/ProhibitMultiplePackages.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::Modules::ProhibitMultiplePackages;
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{Multiple "package" declarations};
23 Readonly::Scalar my $EXPL   => q{Limit to one per file};
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()              }
28 sub default_severity     { return $SEVERITY_HIGH  }
29 sub default_themes       { return qw( core bugs ) }
30 sub applies_to           { return 'PPI::Document' }
31
32 #-----------------------------------------------------------------------------
33
34 sub violates {
35     my ( $self, $elem, $doc ) = @_;
36     my $nodes_ref = $doc->find('PPI::Statement::Package');
37     return if !$nodes_ref;
38     my @matches = @{$nodes_ref} > 1 ? @{$nodes_ref}[ 1 .. $#{$nodes_ref} ] :();
39
40     return map {$self->violation($DESC, $EXPL, $_)} @matches;
41 }
42
43 1;
44
45 __END__
46
47 #-----------------------------------------------------------------------------
48
49 =pod
50
51 =head1 NAME
52
53 Perl::Critic::Policy::Modules::ProhibitMultiplePackages - Put packages (especially subclasses) in separate files.
54
55 =head1 AFFILIATION
56
57 This Policy is part of the core L<Perl::Critic> distribution.
58
59
60 =head1 DESCRIPTION
61
62 Conway doesn't specifically mention this, but I find it annoying when
63 there are multiple packages in the same file.  When searching for
64 methods or keywords in your editor, it makes it hard to find the right
65 chunk of code, especially if each package is a subclass of the same
66 base.
67
68
69 =head1 CONFIGURATION
70
71 This Policy is not configurable except for the standard options.
72
73
74 =head1 AUTHOR
75
76 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
77
78 =head1 COPYRIGHT
79
80 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer.  All rights reserved.
81
82 This program is free software; you can redistribute it and/or modify
83 it under the same terms as Perl itself.  The full text of this license
84 can be found in the LICENSE file included with this module.
85
86 =cut
87
88 # Local Variables:
89 #   mode: cperl
90 #   cperl-indent-level: 4
91 #   fill-column: 78
92 #   indent-tabs-mode: nil
93 #   c-indentation-style: bsd
94 # End:
95 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :