line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Bangs::ProhibitFlagComments; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
3809
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
150
|
|
4
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
124
|
|
5
|
4
|
|
|
4
|
|
21
|
use Perl::Critic::Utils; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
81
|
|
6
|
4
|
|
|
4
|
|
3815
|
use base 'Perl::Critic::Policy'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1453
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.11_02'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#---------------------------------------------------------------------------- |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub supported_parameters { |
13
|
|
|
|
|
|
|
return ( |
14
|
|
|
|
|
|
|
{ |
15
|
7
|
|
|
7
|
0
|
31287
|
name => 'keywords', |
16
|
|
|
|
|
|
|
description => 'Words to prohibit in comments.', |
17
|
|
|
|
|
|
|
behavior => 'string list', |
18
|
|
|
|
|
|
|
default_string => 'XXX FIXME TODO', |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
1
|
29
|
sub default_severity { return $SEVERITY_LOW } |
24
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { return qw( bangs maintenance ) } |
25
|
3
|
|
|
3
|
1
|
16942
|
sub applies_to { return qw( PPI::Token::Comment PPI::Token::Pod ) } |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub violates { |
31
|
7
|
|
|
7
|
1
|
309
|
my ( $self, $elem, $doc ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
7
|
|
|
|
|
11
|
foreach my $keyword ( keys %{ $self->{'_keywords'} } ) { |
|
7
|
|
|
|
|
34
|
|
34
|
19
|
100
|
|
|
|
108
|
if ( index( $elem->content(), $keyword ) != -1 ) { ## no critic (ProhibitMagicNumbers) |
35
|
2
|
|
|
|
|
22
|
my $desc = qq(Flag comment '$keyword' found); |
36
|
2
|
|
|
|
|
14
|
my $expl = qq(Comments containing "$keyword" typically indicate bugs or problems that the developer knows exist); |
37
|
2
|
|
|
|
|
17
|
return $self->violation( $desc, $expl, $elem ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
5
|
|
|
|
|
41
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
46
|
|
|
|
|
|
|
=for stopwords FIXME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 NAME |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Perl::Critic::Policy::Bangs::ProhibitFlagComments - Don't use XXX, TODO, or FIXME. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 AFFILIATION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This Policy is part of the L<Perl::Critic::Bangs> distribution. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 DESCRIPTION |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Programmers often leave comments intended to "flag" themselves to |
59
|
|
|
|
|
|
|
problems later. This policy looks for comments containing 'XXX', |
60
|
|
|
|
|
|
|
'TODO', or 'FIXME'. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 CONFIGURATION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
By default, this policy only looks for 'XXX', 'TODO', or 'FIXME' in |
65
|
|
|
|
|
|
|
comments. You can override this by specifying a value for C<keywords> |
66
|
|
|
|
|
|
|
in your F<.perlcriticrc> file like this: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
[Bangs::ProhibitFlagComments] |
69
|
|
|
|
|
|
|
keywords = XXX TODO FIXME BUG REVIEW |
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 <andy@petdance.com> and Andrew |
83
|
|
|
|
|
|
|
Moore <amoore@mooresystems.com>. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
86
|
|
|
|
|
|
|
it under the terms of the Artistic License 2.0. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |