Add ARM files
[dh-make-perl] / dev / arm / libperl-critic-perl / libperl-critic-perl-1.088 / lib / Perl / Critic / Policy / References / ProhibitDoubleSigils.pm
1 ##############################################################################
2 #      $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/References/ProhibitDoubleSigils.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::References::ProhibitDoubleSigils;
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 $DESC => q{Double-sigil dereference};
23 Readonly::Scalar my $EXPL => [ 228 ];
24
25 #-----------------------------------------------------------------------------
26
27 sub supported_parameters { return ()                    }
28 sub default_severity     { return $SEVERITY_LOW         }
29 sub default_themes       { return qw(core pbp cosmetic) }
30 sub applies_to           { return 'PPI::Token::Cast'    }
31
32 #-----------------------------------------------------------------------------
33
34 sub violates {
35     my ( $self, $elem, undef ) = @_;
36     return if $elem eq q{\\};
37
38     my $sib = $elem->snext_sibling;
39     return if !$sib;
40     if ( ! $sib->isa('PPI::Structure::Block') ) {
41         return $self->violation( $DESC, $EXPL, $elem );
42     }
43     return; #ok!
44 }
45
46 1;
47
48 __END__
49
50 #-----------------------------------------------------------------------------
51
52 =pod
53
54 =head1 NAME
55
56 Perl::Critic::Policy::References::ProhibitDoubleSigils - Write C<@{ $array_ref }> instead of C<@$array_ref>.
57
58 =head1 AFFILIATION
59
60 This Policy is part of the core L<Perl::Critic> distribution.
61
62
63 =head1 DESCRIPTION
64
65 When dereferencing a reference, put braces around the reference to
66 separate the sigils.  Especially for newbies, the braces eliminate any
67 potential confusion about the relative precedence of the sigils.
68
69   push @$array_ref, 'foo', 'bar', 'baz';      #not ok
70   push @{ $array_ref }, 'foo', 'bar', 'baz';  #ok
71
72   foreach ( keys %$hash_ref ){}               #not ok
73   foreach ( keys %{ $hash_ref } ){}           #ok
74
75
76 =head1 CONFIGURATION
77
78 This Policy is not configurable except for the standard options.
79
80
81 =head1 AUTHOR
82
83 Jeffrey Ryan Thalhammer <thaljef@cpan.org>
84
85 =head1 COPYRIGHT
86
87 Copyright (c) 2005-2008 Jeffrey Ryan Thalhammer.  All rights reserved.
88
89 This program is free software; you can redistribute it and/or modify
90 it under the same terms as Perl itself.  The full text of this license
91 can be found in the LICENSE file included with this module.
92
93 =cut
94
95 # Local Variables:
96 #   mode: cperl
97 #   cperl-indent-level: 4
98 #   fill-column: 78
99 #   indent-tabs-mode: nil
100 #   c-indentation-style: bsd
101 # End:
102 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :