line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Perlsecret; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
284911
|
use 5.006001; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
116
|
|
4
|
3
|
|
|
3
|
|
18
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
89
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
91
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
14
|
use base 'Perl::Critic::Policy'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
3108
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
483280
|
use Carp; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
361
|
|
10
|
3
|
|
|
3
|
|
3598
|
use Data::Dumper; |
|
3
|
|
|
|
|
23227
|
|
|
3
|
|
|
|
|
296
|
|
11
|
3
|
|
|
3
|
|
28
|
use Perl::Critic::Utils; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
77
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Perl::Critic::Policy::Perlsecret - Prevent Perlsecret operators and constants. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 0.0.1 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 AFFILIATION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This is a standalone policy not part of a larger PerlCritic Policies group. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Prevents Perlsecrets appearing in your codebase. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 CONFIGURATION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
... |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 LIMITATIONS |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Probably many... |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Readonly::Scalar my $DESCRIPTION => 'Perlsecret risk.'; |
48
|
|
|
|
|
|
|
Readonly::Scalar my $EXPLANATION => 'Perlsecret detected: %s'; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub default_severity |
51
|
|
|
|
|
|
|
{ |
52
|
26
|
|
|
26
|
1
|
318
|
return $Perl::Critic::Utils::SEVERITY_HIGHEST; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub default_themes |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
1
|
1
|
980
|
return qw( perlsecret ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub applies_to |
61
|
|
|
|
|
|
|
{ |
62
|
18
|
|
|
18
|
1
|
233802
|
return qw( |
63
|
|
|
|
|
|
|
PPI::Statement |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub violates { |
68
|
45
|
|
|
45
|
1
|
5428
|
my ( $self, $element, $doc ) = @_; |
69
|
|
|
|
|
|
|
# Eskimo Greeting skipped as only used in one liners |
70
|
45
|
|
|
|
|
1550
|
my %violations = ( |
71
|
|
|
|
|
|
|
'Venus' => qr/\s0\+\s/, #\b so it does not match K.O.T. |
72
|
|
|
|
|
|
|
'Baby Cart' => qr/\@\{\[.*\]\}/, |
73
|
|
|
|
|
|
|
'Bang Bang' => qr/!!/, |
74
|
|
|
|
|
|
|
'Inchworm' => qr/~~/, |
75
|
|
|
|
|
|
|
'Inchworm on a stick' => qr/~-|-~/, |
76
|
|
|
|
|
|
|
'Space Station' => qr/-\+-/, |
77
|
|
|
|
|
|
|
'Goatse' => qr/=\(.*\)=/, |
78
|
|
|
|
|
|
|
'Flaming X-Wing' => qr/=<.*>=~/, |
79
|
|
|
|
|
|
|
'Kite' => qr/~~<>/, |
80
|
|
|
|
|
|
|
'Ornate Double Edged Sword' => qr/<<m=~m>>/, |
81
|
|
|
|
|
|
|
'Flathead' => qr/-=!!|-=!/, |
82
|
|
|
|
|
|
|
'Phillips' => qr/\+=!!|\+=!/, |
83
|
|
|
|
|
|
|
'Torx' => qr/\*=!!|\*=!/, |
84
|
|
|
|
|
|
|
'Pozidriv' => qr/x=!!|x=!/, |
85
|
|
|
|
|
|
|
'Winking fat comma' => qr/,=>/, |
86
|
|
|
|
|
|
|
'Enterprise' => qr/\(.*\)x!!/, |
87
|
|
|
|
|
|
|
'Key of truth' => qr/0\+!!/, |
88
|
|
|
|
|
|
|
'Abbott and Costello' => qr/\|\|\(\)/, |
89
|
|
|
|
|
|
|
'Leaning Abbott and Costello' => qr/\/\/\(\)/, |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
45
|
|
|
|
|
315
|
for my $policy ( keys %violations ) { |
93
|
554
|
100
|
|
|
|
25379
|
if ( $element =~ $violations{$policy} ) { |
94
|
26
|
|
|
|
|
2518
|
return $self->violation( $DESCRIPTION . " $policy ", |
95
|
|
|
|
|
|
|
$EXPLANATION, $element ); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
19
|
|
|
|
|
667
|
return; # No matches return i.e. no violations |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 BUGS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
108
|
|
|
|
|
|
|
L<https://github.com/lancew/Perl-Critic-Policy-Perlsecret/issues>. |
109
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
110
|
|
|
|
|
|
|
your bug as I make changes. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SUPPORT |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
perldoc Perl::Critic::Policy::Perlsecret |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
You can also look for information at: |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=over 4 |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * GitHub (report bugs there) |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L<https://github.com/lancew/Perl-Critic-Policy-Perlsecret/issues> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Perl-Critic-Policy-Perlsecret> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * CPAN Ratings |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Perl-Critic-Policy-Perlsecret> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * MetaCPAN |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L<https://metacpan.org/release/Perl-Critic-Policy-Perlsecret> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L<Lance Wicks|https://metacpan.org/author/LANCEW>, |
146
|
|
|
|
|
|
|
C<< <lancew at cpan.org> >>. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright 2014 Lance Wicks. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under |
154
|
|
|
|
|
|
|
the terms of the GNU General Public License version 3 as published by the Free |
155
|
|
|
|
|
|
|
Software Foundation. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
158
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
159
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
162
|
|
|
|
|
|
|
this program. If not, see http://www.gnu.org/licenses/ |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |