| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Bangs::ProhibitCommentedOutCode; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
3586
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
133
|
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
97
|
|
|
5
|
4
|
|
|
4
|
|
21
|
use Perl::Critic::Utils; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
72
|
|
|
6
|
4
|
|
|
4
|
|
3871
|
use base 'Perl::Critic::Policy'; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
1028
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.11_02'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub supported_parameters { |
|
13
|
|
|
|
|
|
|
return ( |
|
14
|
|
|
|
|
|
|
{ |
|
15
|
8
|
|
|
8
|
0
|
50669
|
name => 'commentedcoderegex', |
|
16
|
|
|
|
|
|
|
description => 'Regular expression to use to look for code in comments.', |
|
17
|
|
|
|
|
|
|
behavior => 'string', |
|
18
|
|
|
|
|
|
|
default_string => '\$[A-Za-z_].*=', ## no critic (RequireInterpolationOfMetachars) |
|
19
|
|
|
|
|
|
|
}, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
1
|
100
|
sub default_severity { return $SEVERITY_LOW } |
|
24
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { return qw( bangs maintenance ) } |
|
25
|
4
|
|
|
4
|
1
|
37065
|
sub applies_to { return 'PPI::Token::Comment' } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub violates { |
|
30
|
12
|
|
|
12
|
1
|
1063
|
my ( $self, $elem, $doc ) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
12
|
100
|
|
|
|
155
|
if ( $elem =~ $self->{_commentedcoderegex} ) { |
|
33
|
3
|
|
|
|
|
35
|
my $desc = q(Code found in comment); |
|
34
|
3
|
|
|
|
|
6
|
my $expl = q(Commented-out code found can be confusing); |
|
35
|
3
|
|
|
|
|
25
|
return $self->violation( $desc, $expl, $elem ); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
9
|
|
|
|
|
73
|
return; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |
|
44
|
|
|
|
|
|
|
=for stopwords regex |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Perl::Critic::Policy::Bangs::ProhibitCommentedOutCode - Commented-out code is usually noise. It should be removed. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This Policy is part of the L<Perl::Critic::Bangs> distribution. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Commented-out code is often a sign of a place where the developer |
|
57
|
|
|
|
|
|
|
is unsure of how the code should be. If historical information |
|
58
|
|
|
|
|
|
|
about the code is important, then keep it in your version control |
|
59
|
|
|
|
|
|
|
system. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
By default, this policy attempts to look for commented out code by |
|
64
|
|
|
|
|
|
|
looking for variable assignments in code as represented by the regular |
|
65
|
|
|
|
|
|
|
expression C<qr/\$[A-Za-z_].*=/> found in a comment. You can change |
|
66
|
|
|
|
|
|
|
that regex by specifying a value for C<coderegex>. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
[Bangs::ProhibitCommentedOutCode] |
|
69
|
|
|
|
|
|
|
coderegex = \$[A-Za-z_].*=/ |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Andrew Moore <amoore@mooresystems.com> |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 ACKNOWLEDGMENTS |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Adapted from policies by Jeffrey Ryan Thalhammer <thaljef@cpan.org>, |
|
78
|
|
|
|
|
|
|
Based on App::Fluff by Andy Lester, "<andy at petdance.com>" |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Copyright (C) 2006-2013 Andy Lester and Andrew Moore |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
85
|
|
|
|
|
|
|
it under the terms of the Artistic License 2.0. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |