| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Variables::ProtectPrivateVars; |
|
2
|
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
25952
|
use 5.010001; |
|
|
40
|
|
|
|
|
184
|
|
|
4
|
40
|
|
|
40
|
|
301
|
use strict; |
|
|
40
|
|
|
|
|
134
|
|
|
|
40
|
|
|
|
|
873
|
|
|
5
|
40
|
|
|
40
|
|
251
|
use warnings; |
|
|
40
|
|
|
|
|
154
|
|
|
|
40
|
|
|
|
|
1244
|
|
|
6
|
40
|
|
|
40
|
|
351
|
use Readonly; |
|
|
40
|
|
|
|
|
168
|
|
|
|
40
|
|
|
|
|
2201
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
363
|
use Perl::Critic::Utils qw{ :severities }; |
|
|
40
|
|
|
|
|
147
|
|
|
|
40
|
|
|
|
|
2063
|
|
|
9
|
40
|
|
|
40
|
|
5263
|
use parent 'Perl::Critic::Policy'; |
|
|
40
|
|
|
|
|
141
|
|
|
|
40
|
|
|
|
|
871
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.150'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Private variable used}; |
|
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Use published APIs}; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
19
|
|
|
|
|
|
|
|
|
20
|
89
|
|
|
89
|
0
|
1616
|
sub supported_parameters { return () } |
|
21
|
74
|
|
|
74
|
1
|
300
|
sub default_severity { return $SEVERITY_MEDIUM } |
|
22
|
74
|
|
|
74
|
1
|
293
|
sub default_themes { return qw(core maintenance certrule ) } |
|
23
|
30
|
|
|
30
|
1
|
70
|
sub applies_to { return 'PPI::Token::Symbol' } |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub violates { |
|
28
|
172
|
|
|
172
|
1
|
298
|
my ( $self, $elem, undef ) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
172
|
50
|
|
|
|
276
|
if ( $elem =~ m{ \w::_\w+ \z }xms ) { |
|
31
|
0
|
|
|
|
|
0
|
return $self->violation( $DESC, $EXPL, $elem ); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
172
|
|
|
|
|
723
|
return; #ok! |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Perl::Critic::Policy::Variables::ProtectPrivateVars - Prevent access to private vars in other packages. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
|
52
|
|
|
|
|
|
|
distribution. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
By convention Perl authors (like authors in many other languages) |
|
58
|
|
|
|
|
|
|
indicate private methods and variables by inserting a leading |
|
59
|
|
|
|
|
|
|
underscore before the identifier. This policy catches attempts to |
|
60
|
|
|
|
|
|
|
access private variables from outside the package itself. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 HISTORY |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This policy is inspired by a similar test in L<B::Lint|B::Lint> |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Subroutines::ProtectPrivateSubs|Perl::Critic::Policy::Subroutines::ProtectPrivateSubs> |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHOR |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Chris Dolan <cdolan@cpan.org> |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Copyright (c) 2006-2011 Chris Dolan. |
|
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 : |