| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes; |
|
2
|
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
26420
|
use 5.010001; |
|
|
40
|
|
|
|
|
170
|
|
|
4
|
40
|
|
|
40
|
|
258
|
use strict; |
|
|
40
|
|
|
|
|
107
|
|
|
|
40
|
|
|
|
|
849
|
|
|
5
|
40
|
|
|
40
|
|
208
|
use warnings; |
|
|
40
|
|
|
|
|
103
|
|
|
|
40
|
|
|
|
|
1160
|
|
|
6
|
40
|
|
|
40
|
|
259
|
use Readonly; |
|
|
40
|
|
|
|
|
108
|
|
|
|
40
|
|
|
|
|
2335
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
328
|
use Perl::Critic::Utils qw{ :severities }; |
|
|
40
|
|
|
|
|
100
|
|
|
|
40
|
|
|
|
|
2199
|
|
|
9
|
40
|
|
|
40
|
|
5465
|
use parent 'Perl::Critic::Policy'; |
|
|
40
|
|
|
|
|
104
|
|
|
|
40
|
|
|
|
|
232
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.148'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $NOISE_RX => qr{\A ["'] [^ \w () {} [\] <> ]{1,2} ['"] \z}xms; |
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Quotes used with a noisy string}; |
|
17
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => [ 53 ]; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
20
|
|
|
|
|
|
|
|
|
21
|
93
|
|
|
93
|
0
|
1616
|
sub supported_parameters { return () } |
|
22
|
109
|
|
|
109
|
1
|
467
|
sub default_severity { return $SEVERITY_LOW } |
|
23
|
84
|
|
|
84
|
1
|
407
|
sub default_themes { return qw(core pbp cosmetic) } |
|
24
|
34
|
|
|
34
|
1
|
180
|
sub applies_to { return qw(PPI::Token::Quote::Double |
|
25
|
|
|
|
|
|
|
PPI::Token::Quote::Single) } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub violates { |
|
30
|
107
|
|
|
107
|
1
|
280
|
my ( $self, $elem, undef ) = @_; |
|
31
|
107
|
100
|
|
|
|
460
|
return if $elem !~ $NOISE_RX; |
|
32
|
36
|
|
|
|
|
455
|
my $statement = $elem->statement; |
|
33
|
36
|
50
|
66
|
|
|
944
|
return if $statement |
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
34
|
|
|
|
|
|
|
&& $statement->isa('PPI::Statement::Include') |
|
35
|
|
|
|
|
|
|
&& $statement->type eq 'use' |
|
36
|
|
|
|
|
|
|
&& $statement->module eq 'overload'; |
|
37
|
35
|
|
|
|
|
159
|
return $self->violation( $DESC, $EXPL, $elem ); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
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 : |