1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Policy/Variables/ProtectPrivateVars.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Policy::Variables::ProtectPrivateVars;
15 use Perl::Critic::Utils qw{ :severities };
16 use base 'Perl::Critic::Policy';
18 our $VERSION = '1.088';
20 #-----------------------------------------------------------------------------
22 Readonly::Scalar my $DESC => q{Private variable used};
23 Readonly::Scalar my $EXPL => q{Use published APIs};
25 #-----------------------------------------------------------------------------
27 sub supported_parameters { return () }
28 sub default_severity { return $SEVERITY_MEDIUM }
29 sub default_themes { return qw(core maintenance) }
30 sub applies_to { return 'PPI::Token::Symbol' }
32 #-----------------------------------------------------------------------------
35 my ( $self, $elem, undef ) = @_;
37 if ( $elem =~ m{ \w::_\w+ \z }xms ) {
38 return $self->violation( $DESC, $EXPL, $elem );
47 #-----------------------------------------------------------------------------
53 Perl::Critic::Policy::Variables::ProtectPrivateVars - Prevent access to private vars in other packages.
57 This Policy is part of the core L<Perl::Critic> distribution.
62 By convention Perl authors (like authors in many other languages)
63 indicate private methods and variables by inserting a leading
64 underscore before the identifier. This policy catches attempts to
65 access private variables from outside the package itself.
70 This Policy is not configurable except for the standard options.
75 This policy is inspired by a similar test in L<B::Lint>
79 L<Perl::Critic::Policy::Subroutines::ProtectPrivateSubs>
83 Chris Dolan <cdolan@cpan.org>
87 Copyright (c) 2006-2008 Chris Dolan. All rights reserved.
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.
97 # cperl-indent-level: 4
99 # indent-tabs-mode: nil
100 # c-indentation-style: bsd
102 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :