line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 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
|
|
|
|
|
|
|
# perlcritic -s ProhibitParagraphTwoDots ProhibitParagraphTwoDots.pm |
20
|
|
|
|
|
|
|
# perlcritic -s ProhibitParagraphTwoDots /usr/share/perl5/HTML/FormatText/WithLinks.pm |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Maybe foo.Z<>. to disguise two dots? |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Perl::Critic::Policy::Documentation::ProhibitParagraphTwoDots; |
26
|
40
|
|
|
40
|
|
25267
|
use 5.006; |
|
40
|
|
|
|
|
129
|
|
27
|
40
|
|
|
40
|
|
185
|
use strict; |
|
40
|
|
|
|
|
77
|
|
|
40
|
|
|
|
|
897
|
|
28
|
40
|
|
|
40
|
|
164
|
use warnings; |
|
40
|
|
|
|
|
75
|
|
|
40
|
|
|
|
|
836
|
|
29
|
40
|
|
|
40
|
|
174
|
use base 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
87
|
|
|
40
|
|
|
|
|
3858
|
|
30
|
40
|
|
|
40
|
|
153653
|
use Perl::Critic::Utils; |
|
40
|
|
|
|
|
100
|
|
|
40
|
|
|
|
|
528
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
33
|
|
|
|
|
|
|
#use Smart::Comments; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = 97; |
36
|
|
|
|
|
|
|
|
37
|
40
|
|
|
40
|
|
44016
|
use constant supported_parameters => (); |
|
40
|
|
|
|
|
82
|
|
|
40
|
|
|
|
|
2116
|
|
38
|
40
|
|
|
40
|
|
214
|
use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOWEST; |
|
40
|
|
|
|
|
75
|
|
|
40
|
|
|
|
|
1908
|
|
39
|
40
|
|
|
40
|
|
217
|
use constant default_themes => qw(pulp cosmetic); |
|
40
|
|
|
|
|
76
|
|
|
40
|
|
|
|
|
1888
|
|
40
|
40
|
|
|
40
|
|
225
|
use constant applies_to => 'PPI::Document'; |
|
40
|
|
|
|
|
73
|
|
|
40
|
|
|
|
|
4675
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub violates { |
43
|
29
|
|
|
29
|
1
|
583288
|
my ($self, $elem, $document) = @_; |
44
|
|
|
|
|
|
|
### ProhibitParagraphTwoDots on: $elem->content |
45
|
|
|
|
|
|
|
|
46
|
29
|
|
|
|
|
330
|
my $parser = Perl::Critic::Pulp::PodParser::ProhibitParagraphTwoDots->new |
47
|
|
|
|
|
|
|
(policy => $self); |
48
|
29
|
|
|
|
|
103
|
$parser->parse_from_elem ($elem); |
49
|
29
|
|
|
|
|
106
|
return $parser->violations; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Perl::Critic::Pulp::PodParser::ProhibitParagraphTwoDots; |
53
|
40
|
|
|
40
|
|
250
|
use strict; |
|
40
|
|
|
|
|
81
|
|
|
40
|
|
|
|
|
837
|
|
54
|
40
|
|
|
40
|
|
221
|
use warnings; |
|
40
|
|
|
|
|
74
|
|
|
40
|
|
|
|
|
1035
|
|
55
|
40
|
|
|
40
|
|
574
|
use Pod::ParseLink; |
|
40
|
|
|
|
|
812
|
|
|
40
|
|
|
|
|
1614
|
|
56
|
40
|
|
|
40
|
|
197
|
use base 'Perl::Critic::Pulp::PodParser'; |
|
40
|
|
|
|
|
94
|
|
|
40
|
|
|
|
|
15232
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub command { |
59
|
31
|
|
|
31
|
|
2224
|
my $self = shift; |
60
|
31
|
|
|
|
|
135
|
$self->SUPER::command(@_); # maintain 'in_begin' |
61
|
31
|
|
|
|
|
96
|
return $self->command_as_textblock(@_); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub textblock { |
65
|
51
|
|
|
51
|
|
1255
|
my ($self, $text, $linenum, $pod_para) = @_; |
66
|
|
|
|
|
|
|
### textblock: "linenum=$linenum" |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# "=begin :foo" is markup, check it. Other =begin is not markup. |
69
|
51
|
100
|
66
|
|
|
139
|
unless ($self->{'in_begin'} eq '' || $self->{'in_begin'} =~ /^:/) { |
70
|
1
|
|
|
|
|
34
|
return ''; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
50
|
|
|
|
|
2070
|
my $str = $self->interpolate($text, $linenum); |
74
|
|
|
|
|
|
|
### $text |
75
|
|
|
|
|
|
|
### $str |
76
|
|
|
|
|
|
|
|
77
|
50
|
100
|
|
|
|
222
|
if ($str =~ /(?<!\.)(\.\.\s*)$/sg) { |
78
|
13
|
|
|
|
|
64
|
$text =~ /(\s*)$/; |
79
|
13
|
|
|
|
|
33
|
my $pos = length($text) - length($1); # end of $text |
80
|
|
|
|
|
|
|
### $pos |
81
|
13
|
|
|
|
|
54
|
$self->violation_at_linenum_and_textpos |
82
|
|
|
|
|
|
|
("Paragraph ends with two dots (stray extra?)", $linenum, $text, $pos); |
83
|
|
|
|
|
|
|
} |
84
|
50
|
|
|
|
|
489
|
return ''; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
sub interior_sequence { |
87
|
7
|
|
|
7
|
|
29
|
my ($self, $cmd, $text, $pod_seq) = @_; |
88
|
7
|
100
|
|
|
|
28
|
if ($cmd eq 'X') { |
|
|
100
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# index entry, no text output, but keep newlines for linenum |
90
|
1
|
|
|
|
|
3
|
$text =~ tr/\n//cd; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} elsif ($cmd eq 'L') { |
93
|
3
|
|
|
|
|
10
|
my ($display, $inferred, $name, $section, $type) |
94
|
|
|
|
|
|
|
= Pod::ParseLink::parselink ($text); |
95
|
|
|
|
|
|
|
### $display |
96
|
|
|
|
|
|
|
### $inferred |
97
|
|
|
|
|
|
|
### $name |
98
|
3
|
|
|
|
|
194
|
return $inferred; # the display part, or the name part if no display |
99
|
|
|
|
|
|
|
} |
100
|
4
|
|
|
|
|
108
|
return $text; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
__END__ |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=for stopwords Ryde |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 NAME |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Perl::Critic::Policy::Documentation::ProhibitParagraphTwoDots - don't end a paragraph with two dots |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DESCRIPTION |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This policy is part of the L<C<Perl::Critic::Pulp>|Perl::Critic::Pulp> |
115
|
|
|
|
|
|
|
add-on. It asks you not to end a POD paragraph with two dots, |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Some thing.. # bad |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is a surprisingly easy typo, but of course is entirely cosmetic and on |
120
|
|
|
|
|
|
|
that basis this policy is lowest severity and under the "cosmetic" theme |
121
|
|
|
|
|
|
|
(see L<Perl::Critic/POLICY THEMES>). |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Three or more dots as an ellipsis is fine, |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
And some more of this ... # ok |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
and anything within a paragraph is fine, |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Numbers 1 .. 10 are handled. # ok |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Only text paragraphs are checked. Verbatim paragraphs can end with anything |
132
|
|
|
|
|
|
|
at all |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This is an example, |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
example_code (1 .. # ok |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
There might be other dubious paragraph endings this policy could pick up, |
139
|
|
|
|
|
|
|
but things like ";." or ":." can arise from code or smiley faces, so at the |
140
|
|
|
|
|
|
|
moment only two dots are bad. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 Disabling |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If you don't care about this you can disable C<ProhibitParagraphTwoDots> |
145
|
|
|
|
|
|
|
from your F<.perlcriticrc> in the usual way (see |
146
|
|
|
|
|
|
|
L<Perl::Critic/CONFIGURATION>), |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
[-Documentation::ProhibitParagraphTwoDots] |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
A C<## no critic> directive works in new enough C<Perl::Critic>, but if you |
151
|
|
|
|
|
|
|
have an C<__END__> token then any C<no critic> generally must be before |
152
|
|
|
|
|
|
|
that. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 SEE ALSO |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L<Perl::Critic::Pulp>, |
157
|
|
|
|
|
|
|
L<Perl::Critic> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Documentation::ProhibitParagraphEndComma> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 HOME PAGE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L<http://user42.tuxfamily.org/perl-critic-pulp/index.html> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 Kevin Ryde |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it |
170
|
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the Free |
171
|
|
|
|
|
|
|
Software Foundation; either version 3, or (at your option) any later |
172
|
|
|
|
|
|
|
version. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Perl-Critic-Pulp is distributed in the hope that it will be useful, but |
175
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
176
|
|
|
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
177
|
|
|
|
|
|
|
more details. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
180
|
|
|
|
|
|
|
Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |