line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::References::ProhibitDoubleSigils; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
26676
|
use 5.010001; |
|
40
|
|
|
|
|
192
|
|
4
|
40
|
|
|
40
|
|
271
|
use strict; |
|
40
|
|
|
|
|
144
|
|
|
40
|
|
|
|
|
842
|
|
5
|
40
|
|
|
40
|
|
211
|
use warnings; |
|
40
|
|
|
|
|
113
|
|
|
40
|
|
|
|
|
937
|
|
6
|
40
|
|
|
40
|
|
221
|
use Readonly; |
|
40
|
|
|
|
|
105
|
|
|
40
|
|
|
|
|
1951
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
314
|
use Perl::Critic::Utils qw{ :severities }; |
|
40
|
|
|
|
|
101
|
|
|
40
|
|
|
|
|
2128
|
|
9
|
40
|
|
|
40
|
|
5407
|
use parent 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
138
|
|
|
40
|
|
|
|
|
278
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.150'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Double-sigil dereference}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => [ 228 ]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
89
|
|
|
89
|
0
|
1612
|
sub supported_parameters { return () } |
21
|
74
|
|
|
74
|
1
|
303
|
sub default_severity { return $SEVERITY_LOW } |
22
|
84
|
|
|
84
|
1
|
346
|
sub default_themes { return qw(core pbp cosmetic) } |
23
|
30
|
|
|
30
|
1
|
91
|
sub applies_to { return 'PPI::Token::Cast' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub violates { |
28
|
0
|
|
|
0
|
1
|
|
my ( $self, $elem, undef ) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $content = $elem->content(); |
31
|
0
|
0
|
|
|
|
|
return if $content eq q{\\}; |
32
|
0
|
0
|
|
|
|
|
return if $content =~ /[@ $ % * &] [*]/xms; |
33
|
0
|
0
|
|
|
|
|
return if $content eq q{$#*}; ## no critic (RequireInterpolationOfMetachars) |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my $sib = $elem->snext_sibling; |
36
|
0
|
0
|
|
|
|
|
return if !$sib; |
37
|
0
|
0
|
0
|
|
|
|
if ( ! $sib->isa('PPI::Structure::Block') && ! $sib->isa('PPI::Structure::Subscript') ) { |
38
|
0
|
|
|
|
|
|
return $self->violation( $DESC, $EXPL, $elem ); |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
return; #ok! |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 NAME |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Perl::Critic::Policy::References::ProhibitDoubleSigils - Write C<@{ $array_ref }> instead of C<@$array_ref>. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AFFILIATION |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
58
|
|
|
|
|
|
|
distribution. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
When dereferencing a reference, put braces around the reference to |
64
|
|
|
|
|
|
|
separate the sigils. Especially for newbies, the braces eliminate any |
65
|
|
|
|
|
|
|
potential confusion about the relative precedence of the sigils. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
push @$array_ref, 'foo', 'bar', 'baz'; #not ok |
68
|
|
|
|
|
|
|
push @{ $array_ref }, 'foo', 'bar', 'baz'; #ok |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
foreach ( keys %$hash_ref ){} #not ok |
71
|
|
|
|
|
|
|
foreach ( keys %{ $hash_ref } ){} #ok |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 CONFIGURATION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 AUTHOR |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright (c) 2005-2023 Imaginative Software Systems. All rights reserved. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
88
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
89
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Local Variables: |
94
|
|
|
|
|
|
|
# mode: cperl |
95
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
96
|
|
|
|
|
|
|
# fill-column: 78 |
97
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
98
|
|
|
|
|
|
|
# c-indentation-style: bsd |
99
|
|
|
|
|
|
|
# End: |
100
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |