« blib/lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitMixedBooleanOperators.pm
↑ Summary
blib/lib/Perl/Critic/Policy/BuiltinFunctions/ProhibitVoidMap.pm »
| 1 | package Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 40 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 40 | our $VERSION = '1.150'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 40 | Readonly::Scalar my $NOISE_RX => qr{\A ["'] [^ \w () {} [\] <> ]{1,2} ['"] \z}xms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 40 | Readonly::Scalar my $DESC => q{Quotes used with a noisy string}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 40 | Readonly::Scalar my $EXPL => [ 53 ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 90 | ▶ | sub supported_parameters { return () } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 106 | ▶ | sub default_severity { return $SEVERITY_LOW } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 84 | ▶ | sub default_themes { return qw(core pbp cosmetic) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 31 | ▶ | sub applies_to { return qw(PPI::Token::Quote::Double | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | PPI::Token::Quote::Single) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | sub violates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 72 | ▶ | my ( $self, $elem, undef ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
violates: called CC=6 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 72 | ▶ | return if $elem !~ $NOISE_RX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 31 | my $statement = $elem->statement; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 31 | ▶ | return if $statement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$statement and $statement->isa("PPI::Statement::Include") and $statement->type eq "use" and $statement->module eq "overload"
$statement and $statement->isa("PPI::Statement::Include") and $statement->type eq "use"
$statement and $statement->isa("PPI::Statement::Include")
MC/DC0%0/4
$statement and $statement->isa("PPI::Statement::Include") and $statement->type eq "use" and $statement->module eq "overload"
$statement
$statement->isa("PPI::Statement::Include")
$statement->type eq "use"
$statement->module eq "overload"
Truth table20%1/5
A and B and C and D
A= $statementB= $statement->isa("PPI::Statement::Include")C= $statement->type eq "use"D= $statement->module eq "overload"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | && $statement->isa('PPI::Statement::Include') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | && $statement->type eq 'use' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | && $statement->module eq 'overload'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 31 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 40 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes - Use C<q{}> or C<qq{}> instead of quotes for awkward-looking strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =head1 AFFILIATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | This Policy is part of the core L<Perl::Critic|Perl::Critic> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | distribution. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | Don't use quotes for one or two-character strings of non-alphanumeric | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | characters (i.e. noise). These tend to be hard to read. For | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | legibility, use C<q{}> or a named value. However, braces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | parentheses and brackets tend to look better in quotes, so those | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | are allowed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $str = join ',', @list; #not ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | $str = join ",", @list; #not ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $str = join q{,}, @list; #better | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $COMMA = q{,}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $str = join $COMMA, @list; #best | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | $lbrace = '('; #ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $rbrace = ')'; #ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | print '(', @list, ')'; #ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | =head1 CONFIGURATION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | This Policy is not configurable except for the standard options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | L<Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes|Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | it under the same terms as Perl itself. The full text of this license | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | can be found in the LICENSE file included with this module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Local Variables: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # mode: cperl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # cperl-indent-level: 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # fill-column: 78 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # c-indentation-style: bsd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # End: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||