| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Perl-Critic-Pulp. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Perl-Critic-Pulp is free software; you can redistribute it and/or modify |
|
6
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the |
|
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 3, or (at your option) any later |
|
8
|
|
|
|
|
|
|
# version. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Perl-Critic-Pulp is distributed in the hope that it will be useful, but |
|
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13
|
|
|
|
|
|
|
# for more details. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
|
16
|
|
|
|
|
|
|
# with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# maybe allow comma for |
|
20
|
|
|
|
|
|
|
# =head1 Foo |
|
21
|
|
|
|
|
|
|
# And something, |
|
22
|
|
|
|
|
|
|
# =head2 Item |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# perlcritic -s ProhibitParagraphEndComma ProhibitParagraphEndComma.pm |
|
25
|
|
|
|
|
|
|
# perlcritic -s ProhibitParagraphEndComma /usr/share/perl5/IO/Socket/INET6.pm |
|
26
|
|
|
|
|
|
|
# perlcritic -s ProhibitParagraphEndComma /usr/share/perl5/MIME/Body.pm /usr/share/perl5/XML/Twig.pm |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package Perl::Critic::Policy::Documentation::ProhibitParagraphEndComma; |
|
30
|
40
|
|
|
40
|
|
26638
|
use 5.006; |
|
|
40
|
|
|
|
|
144
|
|
|
31
|
40
|
|
|
40
|
|
190
|
use strict; |
|
|
40
|
|
|
|
|
73
|
|
|
|
40
|
|
|
|
|
726
|
|
|
32
|
40
|
|
|
40
|
|
177
|
use warnings; |
|
|
40
|
|
|
|
|
79
|
|
|
|
40
|
|
|
|
|
912
|
|
|
33
|
40
|
|
|
40
|
|
179
|
use base 'Perl::Critic::Policy'; |
|
|
40
|
|
|
|
|
78
|
|
|
|
40
|
|
|
|
|
3821
|
|
|
34
|
40
|
|
|
40
|
|
151436
|
use Perl::Critic::Utils; |
|
|
40
|
|
|
|
|
151
|
|
|
|
40
|
|
|
|
|
544
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
|
37
|
|
|
|
|
|
|
# use Smart::Comments; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our $VERSION = 97; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
40
|
|
|
40
|
|
30784
|
use constant supported_parameters => (); |
|
|
40
|
|
|
|
|
102
|
|
|
|
40
|
|
|
|
|
2240
|
|
|
43
|
40
|
|
|
40
|
|
212
|
use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOWEST; |
|
|
40
|
|
|
|
|
96
|
|
|
|
40
|
|
|
|
|
1963
|
|
|
44
|
40
|
|
|
40
|
|
212
|
use constant default_themes => qw(pulp cosmetic); |
|
|
40
|
|
|
|
|
77
|
|
|
|
40
|
|
|
|
|
2103
|
|
|
45
|
40
|
|
|
40
|
|
330
|
use constant applies_to => 'PPI::Document'; |
|
|
40
|
|
|
|
|
82
|
|
|
|
40
|
|
|
|
|
4653
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub violates { |
|
48
|
7
|
|
|
7
|
1
|
588871
|
my ($self, $elem, $document) = @_; |
|
49
|
|
|
|
|
|
|
### ProhibitParagraphEndComma on: $elem->content |
|
50
|
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
123
|
my $parser = Perl::Critic::Pulp::PodParser::ProhibitParagraphEndComma->new |
|
52
|
|
|
|
|
|
|
(policy => $self); |
|
53
|
7
|
|
|
|
|
24
|
$parser->parse_from_elem ($elem); |
|
54
|
7
|
|
|
|
|
21
|
$parser->check_last; |
|
55
|
7
|
|
|
|
|
18
|
return $parser->violations; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package Perl::Critic::Pulp::PodParser::ProhibitParagraphEndComma; |
|
59
|
40
|
|
|
40
|
|
260
|
use strict; |
|
|
40
|
|
|
|
|
91
|
|
|
|
40
|
|
|
|
|
829
|
|
|
60
|
40
|
|
|
40
|
|
177
|
use warnings; |
|
|
40
|
|
|
|
|
80
|
|
|
|
40
|
|
|
|
|
1063
|
|
|
61
|
40
|
|
|
40
|
|
200
|
use base 'Perl::Critic::Pulp::PodParser'; |
|
|
40
|
|
|
|
|
84
|
|
|
|
40
|
|
|
|
|
17622
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub new { |
|
64
|
7
|
|
|
7
|
|
15
|
my $class = shift; |
|
65
|
|
|
|
|
|
|
### new() ... |
|
66
|
7
|
|
|
|
|
89
|
return $class->SUPER::new (last_text => '', |
|
67
|
|
|
|
|
|
|
last_command => '', |
|
68
|
|
|
|
|
|
|
@_); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
sub command { |
|
71
|
14
|
|
|
14
|
|
1181
|
my ($self, $command, $text, $linenum, $paraobj) = @_; |
|
72
|
|
|
|
|
|
|
### command(): $command |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# "=begin :foo" means pod markup continues. Ignore the =begin and |
|
75
|
|
|
|
|
|
|
# continue processing POD within it. Any other begin is a new block |
|
76
|
|
|
|
|
|
|
# something and preceding comma not allowed. |
|
77
|
|
|
|
|
|
|
# |
|
78
|
14
|
100
|
66
|
|
|
95
|
if ($command eq 'for' |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|| $command eq 'pod' |
|
80
|
|
|
|
|
|
|
|| ($command eq 'begin' && $text =~ /^\s*:/) |
|
81
|
|
|
|
|
|
|
|| $command eq 'end') { |
|
82
|
11
|
|
|
|
|
83
|
return; # ignore these completely |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
3
|
50
|
33
|
|
|
13
|
if ($command eq 'item' && $self->{'last_command'} eq 'item') { |
|
|
|
100
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Paragraphs in =item list can end in successive commas. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} elsif ($command eq 'over') { |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} else { |
|
91
|
2
|
|
|
|
|
6
|
$self->check_last; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
3
|
|
|
|
|
5
|
$self->{'last_text'} = ''; |
|
94
|
3
|
|
|
|
|
29
|
$self->{'last_command'} = $command; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
sub textblock { |
|
97
|
10
|
|
|
10
|
|
593
|
my ($self, $text, $linenum, $paraobj) = @_; |
|
98
|
|
|
|
|
|
|
### textblock(): $text |
|
99
|
10
|
|
|
|
|
77
|
$self->check_last; |
|
100
|
|
|
|
|
|
|
# sometimes $text=undef from Pod::Parser |
|
101
|
10
|
50
|
|
|
|
24
|
if (! defined $text) { $text = ''; } |
|
|
0
|
|
|
|
|
0
|
|
|
102
|
10
|
|
|
|
|
18
|
$self->{'last_linenum'} = $linenum; |
|
103
|
10
|
|
|
|
|
126
|
$self->{'last_text'} = $text; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
sub verbatim { |
|
106
|
3
|
|
|
3
|
|
161
|
my ($self, $text, $linenum, $paraobj) = @_; |
|
107
|
|
|
|
|
|
|
# anything before a verbatim is ok |
|
108
|
3
|
|
|
|
|
29
|
$self->{'last_text'} = ''; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub check_last { |
|
112
|
19
|
|
|
19
|
|
33
|
my ($self) = @_; |
|
113
|
|
|
|
|
|
|
### check_last() ... |
|
114
|
|
|
|
|
|
|
### in_begin: $self->{'in_begin'} |
|
115
|
|
|
|
|
|
|
|
|
116
|
19
|
50
|
33
|
|
|
78
|
if ($self->{'in_begin'} && $self->{'in_begin'} !~ /^:/) { |
|
|
|
100
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# =begin block of non-: means not pod markup |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} elsif ($self->{'last_text'} =~ /(,\s*)$/s) { |
|
120
|
|
|
|
|
|
|
### last_text ends comma ... |
|
121
|
3
|
|
|
|
|
9
|
my $pos = length($self->{'last_text'}) - length($1); # position of comma |
|
122
|
|
|
|
|
|
|
$self->violation_at_linenum_and_textpos |
|
123
|
|
|
|
|
|
|
("Paragraph ends with comma", |
|
124
|
3
|
|
|
|
|
17
|
$self->{'last_linenum'}, $self->{'last_text'}, $pos); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
19
|
|
|
|
|
40
|
$self->{'last_text'} = ''; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
|
130
|
|
|
|
|
|
|
__END__ |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=for stopwords Ryde |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 NAME |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Perl::Critic::Policy::Documentation::ProhibitParagraphEndComma - avoid comma at end of section |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This policy is part of the L<C<Perl::Critic::Pulp>|Perl::Critic::Pulp> |
|
141
|
|
|
|
|
|
|
add-on. It asks you not to end a POD paragraph with a comma. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Some text, # bad, meant to be a full-stop? |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Some more text. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Usually such a comma is meant to be a full-stop, or perhaps omitted at the |
|
148
|
|
|
|
|
|
|
end of a "SEE ALSO" list |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=for ProhibitVerbatimMarkup allow next 2 |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L<Foo>, |
|
155
|
|
|
|
|
|
|
L<Bar>, # bad, meant to be omitted? |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
A paragraph before an C<=over> or a verbatim block is allowed to end with a |
|
158
|
|
|
|
|
|
|
comma, that being taken as introducing a quotation or example, |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
For example, # ok, introduce an example |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
foo(1+2+3) |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Or one of, # ok, introduce an itemized list |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item Foo |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 Disabling |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
If you don't care about this you can disable C<ProhibitParagraphEndComma> |
|
173
|
|
|
|
|
|
|
from your F<.perlcriticrc> in the usual way (see |
|
174
|
|
|
|
|
|
|
L<Perl::Critic/CONFIGURATION>), |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
[-Documentation::ProhibitParagraphEndComma] |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L<Perl::Critic::Pulp>, L<Perl::Critic> |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Documentation::ProhibitParagraphTwoDots> |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 HOME PAGE |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
http://user42.tuxfamily.org/perl-critic-pulp/index.html |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it |
|
193
|
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the Free |
|
194
|
|
|
|
|
|
|
Software Foundation; either version 3, or (at your option) any later |
|
195
|
|
|
|
|
|
|
version. |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Perl-Critic-Pulp is distributed in the hope that it will be useful, but |
|
198
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
199
|
|
|
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
200
|
|
|
|
|
|
|
more details. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
203
|
|
|
|
|
|
|
Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |