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 / ValuesAndExpressions / ProhibitNoisyQuotes.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitNoisyQuotes.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::ValuesAndExpressions::ProhibitNoisyQuotes;
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 $NOISE_RX => qr{\A ["|']  [^ \w () {} [\] <> ]{1,2}  ['|"] \z}mx;
23 Readonly::Scalar my $DESC     => q{Quotes used with a noisy string};
24 Readonly::Scalar my $EXPL     => [ 53 ];
25
26 #-----------------------------------------------------------------------------
27
28 sub supported_parameters { return ()                    }
29 sub default_severity     { return $SEVERITY_LOW         }
30 sub default_themes       { return qw(core pbp cosmetic) }
31 sub applies_to           { return qw(PPI::Token::Quote::Double
32                                      PPI::Token::Quote::Single) }
33
34 #-----------------------------------------------------------------------------
35
36 sub violates {
37     my ( $self, $elem, undef ) = @_;
38     return if $elem !~ $NOISE_RX;
39     my $statement = $elem->statement;
40     return if $statement
41         && $statement->isa('PPI::Statement::Include')
42         && $statement->type eq 'use'
43         && $statement->module eq 'overload';
44     return $self->violation( $DESC, $EXPL, $elem );
45 }
46
47 1;
48
49 __END__
50
51 #-----------------------------------------------------------------------------
52
53 =pod
54
55 =head1 NAME
56
57 Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes - Use C<q{}> or C<qq{}> instead of quotes for awkward-looking strings.
58
59 =head1 AFFILIATION
60
61 This Policy is part of the core L<Perl::Critic> distribution.
62
63
64 =head1 DESCRIPTION
65
66 Don't use quotes for one or two-character strings of non-alphanumeric
67 characters (i.e. noise).  These tend to be hard to read.  For
68 legibility, use C<q{}> or a named value.  However, braces,
69 parentheses, and brackets tend do to look better in quotes, so those
70 are allowed.
71
72   $str = join ',', @list;     #not ok
73   $str = join ",", @list;     #not ok
74   $str = join q{,}, @list;    #better
75
76   $COMMA = q{,};
77   $str = join $COMMA, @list;  #best
78
79   $lbrace = '(';          #ok
80   $rbrace = ')';          #ok
81   print '(', @list, ')';  #ok
82
83
84 =head1 CONFIGURATION
85
86 This Policy is not configurable except for the standard options.
87
88
89 =head1 SEE ALSO
90
91 L<Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes>
92
93 =head1 AUTHOR
94
95 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
96
97 =head1 COPYRIGHT
98
99 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer.  All rights reserved.
100
101 This program is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.  The full text of this license
103 can be found in the LICENSE file included with this module.
104
105 =cut
106
107 # Local Variables:
108 #   mode: cperl
109 #   cperl-indent-level: 4
110 #   fill-column: 78
111 #   indent-tabs-mode: nil
112 #   c-indentation-style: bsd
113 # End:
114 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :