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 / Variables / ProhibitPerl4PackageNames.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/Variables/ProhibitPerl4PackageNames.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::Variables::ProhibitPerl4PackageNames;
9
10 use 5.006001;
11 use strict;
12 use warnings;
13 use Readonly;
14
15 use Perl::Critic::Utils qw{ :characters :severities :classification };
16 use base 'Perl::Critic::Policy';
17
18 our $VERSION = '1.088';
19
20 #-----------------------------------------------------------------------------
21
22 Readonly::Scalar my $EXPL =>
23     q{Use double colon (::) to separate package name components instead of single quotes (')};
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()                                        }
28 sub default_severity     { return $SEVERITY_LOW                             }
29 sub default_themes       { return qw(core maintenance)                      }
30 sub applies_to           { return qw( PPI::Token::Word PPI::Token::Symbol ) }
31
32 #-----------------------------------------------------------------------------
33
34 sub violates {
35     my ( $self, $elem, undef ) = @_;
36     my $content = $elem->content();
37
38     if ( (index $content, $QUOTE) < 0 ) {
39         return;
40     }
41
42     if ( $content =~ m< \A [\$@%&*] ' \z >xms ) {
43         # We've found $POSTMATCH.
44         return;
45     }
46
47     if ( $elem->isa('PPI::Token::Word') && is_hash_key($elem) ) {
48         return;
49     }
50
51     return
52         $self->violation(
53             qq{"$content" uses the obsolete single quote package separator."},
54             $EXPL,
55             $elem
56         );
57 }
58
59 #-----------------------------------------------------------------------------
60
61 1;
62
63 __END__
64
65 #-----------------------------------------------------------------------------
66
67 =pod
68
69 =head1 NAME
70
71 Perl::Critic::Policy::Variables::ProhibitPerl4PackageNames - Use double colon (::) to separate package name components instead of single quotes (').
72
73 =head1 AFFILIATION
74
75 This Policy is part of the core L<Perl::Critic> distribution.
76
77
78 =head1 DESCRIPTION
79
80 Perl 5 kept single quotes (C<'>) as package component separators in
81 order to remain backward compatible with prior C<perl>s, but advocated
82 using double colon (C<::>) instead.  In the more than a decade since
83 Perl 5, double colons have been overwhelmingly adopted and most people
84 are not even aware that the single quote can be used in this manner.
85 So, unless you're trying to obfuscate your code, don't use them.
86
87   package Foo::Bar::Baz;    #ok
88   package Foo'Bar'Baz;      #not ok
89
90
91 =head1 CONFIGURATION
92
93 This Policy is not configurable except for the standard options.
94
95
96 =head1 SEE ALSO
97
98 L<perlmod>
99
100 =head1 AUTHOR
101
102 Elliot Shank C<< <perl@galumph.com> >>
103
104 =head1 COPYRIGHT
105
106 Copyright (c) 2007-2008 Elliot Shank.  All rights reserved.
107
108 This program is free software; you can redistribute it and/or modify
109 it under the same terms as Perl itself.  The full text of this license
110 can be found in the LICENSE file included with this module.
111
112 =cut
113
114 # Local Variables:
115 #   mode: cperl
116 #   cperl-indent-level: 4
117 #   fill-column: 78
118 #   indent-tabs-mode: nil
119 #   c-indentation-style: bsd
120 # End:
121 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :