line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 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
|
|
|
|
|
|
|
package Perl::Critic::Policy::Documentation::ProhibitBadAproposMarkup; |
20
|
40
|
|
|
40
|
|
33661
|
use 5.006; |
|
40
|
|
|
|
|
154
|
|
21
|
40
|
|
|
40
|
|
225
|
use strict; |
|
40
|
|
|
|
|
99
|
|
|
40
|
|
|
|
|
863
|
|
22
|
40
|
|
|
40
|
|
241
|
use warnings; |
|
40
|
|
|
|
|
99
|
|
|
40
|
|
|
|
|
1141
|
|
23
|
40
|
|
|
40
|
|
329
|
use base 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
96
|
|
|
40
|
|
|
|
|
4841
|
|
24
|
40
|
|
|
40
|
|
197626
|
use Perl::Critic::Utils; |
|
40
|
|
|
|
|
99
|
|
|
40
|
|
|
|
|
818
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
27
|
|
|
|
|
|
|
# use Smart::Comments; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = 99; |
30
|
|
|
|
|
|
|
|
31
|
40
|
|
|
40
|
|
36135
|
use constant supported_parameters => (); |
|
40
|
|
|
|
|
187
|
|
|
40
|
|
|
|
|
2818
|
|
32
|
40
|
|
|
40
|
|
321
|
use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOW; |
|
40
|
|
|
|
|
120
|
|
|
40
|
|
|
|
|
2434
|
|
33
|
40
|
|
|
40
|
|
265
|
use constant default_themes => qw(pulp cosmetic); |
|
40
|
|
|
|
|
89
|
|
|
40
|
|
|
|
|
2436
|
|
34
|
40
|
|
|
40
|
|
268
|
use constant applies_to => 'PPI::Document'; |
|
40
|
|
|
|
|
111
|
|
|
40
|
|
|
|
|
5438
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub violates { |
37
|
13
|
|
|
13
|
1
|
579011
|
my ($self, $elem, $document) = @_; |
38
|
13
|
|
|
|
|
344
|
my $parser = Perl::Critic::Pulp::PodParser::ProhibitBadAproposMarkup->new |
39
|
|
|
|
|
|
|
(policy => $self); |
40
|
13
|
|
|
|
|
82
|
$parser->parse_from_elem ($elem); |
41
|
13
|
|
|
|
|
354
|
return $parser->violations; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
package Perl::Critic::Pulp::PodParser::ProhibitBadAproposMarkup; |
45
|
40
|
|
|
40
|
|
302
|
use strict; |
|
40
|
|
|
|
|
107
|
|
|
40
|
|
|
|
|
1137
|
|
46
|
40
|
|
|
40
|
|
250
|
use warnings; |
|
40
|
|
|
|
|
90
|
|
|
40
|
|
|
|
|
1460
|
|
47
|
40
|
|
|
40
|
|
252
|
use base 'Perl::Critic::Pulp::PodParser'; |
|
40
|
|
|
|
|
95
|
|
|
40
|
|
|
|
|
17409
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub command { |
50
|
23
|
|
|
23
|
|
2431
|
my $self = shift; |
51
|
23
|
|
|
|
|
71
|
my ($command, $text, $linenum, $paraobj) = @_; |
52
|
|
|
|
|
|
|
### command: $command |
53
|
|
|
|
|
|
|
### $text |
54
|
23
|
|
|
|
|
126
|
$self->SUPER::command(@_); # maintain 'in_begin' |
55
|
|
|
|
|
|
|
|
56
|
23
|
100
|
|
|
|
80
|
if ($command eq 'head1') { |
57
|
14
|
100
|
|
|
|
91
|
$self->{'in_NAME'} = ($text =~ /^NAME\s*$/ ? 1 : 0); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
### in_NAME now: $self->{'in_NAME'} |
60
|
23
|
|
|
|
|
388
|
return ''; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub textblock { |
64
|
16
|
|
|
16
|
|
1066
|
my ($self, $text, $linenum, $paraobj) = @_; |
65
|
|
|
|
|
|
|
### textblock ... |
66
|
|
|
|
|
|
|
### in_begin: $self->{'in_begin'} |
67
|
|
|
|
|
|
|
### $text |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Pod::Man accept_targets() are man, MAN, roff, ROFF. Only those =begin |
70
|
|
|
|
|
|
|
# bits are put through to the man page and therefore only those are bad. |
71
|
16
|
100
|
66
|
|
|
94
|
unless ($self->{'in_begin'} eq '' || $self->{'in_begin'} =~ /^:(man|MAN|roff|ROFF)$/) { |
72
|
3
|
|
|
|
|
28
|
return ''; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
13
|
|
|
|
|
1630
|
$self->interpolate ($text, $linenum); |
76
|
13
|
|
|
|
|
324
|
return ''; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub interior_sequence { |
80
|
12
|
|
|
12
|
|
61
|
my ($self, $command, $arg, $seq_obj) = @_; |
81
|
|
|
|
|
|
|
### interior: $command |
82
|
|
|
|
|
|
|
### $arg |
83
|
|
|
|
|
|
|
### $seq_obj |
84
|
|
|
|
|
|
|
### seq raw_text: $seq_obj->raw_text |
85
|
|
|
|
|
|
|
### seq left_delimiter: $seq_obj->left_delimiter |
86
|
|
|
|
|
|
|
### seq outer: do {my $outer=$seq_obj->nested; $outer&&$outer->cmd_name} |
87
|
|
|
|
|
|
|
|
88
|
12
|
100
|
100
|
|
|
91
|
if ($self->{'in_NAME'} && $command eq 'C') { |
89
|
8
|
|
|
|
|
72
|
my ($filename, $linenum) = $seq_obj->file_line; |
90
|
|
|
|
|
|
|
|
91
|
8
|
|
|
|
|
59
|
$self->violation_at_linenum |
92
|
|
|
|
|
|
|
('C<> markup in NAME section is bad for "apropos".', |
93
|
|
|
|
|
|
|
$linenum); |
94
|
|
|
|
|
|
|
} |
95
|
12
|
|
|
|
|
536
|
return ''; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
__END__ |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=for stopwords builtin Ryde nroff |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 NAME |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Perl::Critic::Policy::Documentation::ProhibitBadAproposMarkup - don't use CE<lt>E<gt> markup in a NAME section |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This policy is part of the L<C<Perl::Critic::Pulp>|Perl::Critic::Pulp> |
110
|
|
|
|
|
|
|
add-on. It asks you not to write CE<lt>E<gt> markup in the NAME section of |
111
|
|
|
|
|
|
|
the POD because it comes out badly in the man-db "apropos" database. For |
112
|
|
|
|
|
|
|
example, |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=for ProhibitVerbatimMarkup allow next 2 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 NAME |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
foo - like the C<bar> program # bad |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
C<pod2man> formats "CE<lt>E<gt>" using nroff macros which "man-db"'s |
121
|
|
|
|
|
|
|
C<lexgrog> program doesn't expand, resulting in unattractive description |
122
|
|
|
|
|
|
|
lines from C<apropos> like |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
foo - like the *(C`bar*(C' program |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=for ProhibitUnbalancedParens allow next |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Man's actual formatted output is fine, and the desired text is in there, |
129
|
|
|
|
|
|
|
just surrounded by C<*(C> bits. On that basis this policy is low severity |
130
|
|
|
|
|
|
|
and under the "cosmetic" theme (see L<Perl::Critic/POLICY THEMES>). |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The NAME section is everything from C<=head1 NAME> to the next C<=head1>. |
133
|
|
|
|
|
|
|
Other markup like "BE<lt>E<gt>", "IE<lt>E<gt>" and "FE<lt>E<gt>" is allowed |
134
|
|
|
|
|
|
|
because C<pod2man> uses builtin C<\fB> etc directives for them, which |
135
|
|
|
|
|
|
|
C<lexgrog> recognises. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
C<=begin :man> and C<=begin :roff> blocks are checked since C<Pod::Man> |
138
|
|
|
|
|
|
|
processes those. Other C<=begin> blocks are ignored as they won't appear in |
139
|
|
|
|
|
|
|
the roff output. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 Disabling |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
If want markup in the NAME line, perhaps if printed output is more important |
144
|
|
|
|
|
|
|
than C<apropos>, then you can always disable from your F<.perlcriticrc> in |
145
|
|
|
|
|
|
|
the usual way (see L<Perl::Critic/CONFIGURATION>), |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
[-Documentation::ProhibitBadAproposMarkup] |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Or in an individual file with the usual C<## no critic> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
## no critic (ProhibitBadAproposMarkup) |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
though if the NAME part is after an C<__END__> token then C<Perl::Critic> |
154
|
|
|
|
|
|
|
1.112 or higher is required (and the annotation must be before the |
155
|
|
|
|
|
|
|
C<__END__>). |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SEE ALSO |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<Perl::Critic::Pulp>, |
160
|
|
|
|
|
|
|
L<Perl::Critic>, |
161
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Documentation::RequirePackageMatchesPodName>, |
162
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Documentation::RequirePodSections>, |
163
|
|
|
|
|
|
|
L<Perl::Critic::Policy::Documentation::ProhibitVerbatimMarkup> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<man(1)>, L<apropos(1)>, L<lexgrog(1)> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 HOME PAGE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<http://user42.tuxfamily.org/perl-critic-pulp/index.html> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 COPYRIGHT |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it |
176
|
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the Free |
177
|
|
|
|
|
|
|
Software Foundation; either version 3, or (at your option) any later |
178
|
|
|
|
|
|
|
version. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Perl-Critic-Pulp is distributed in the hope that it will be useful, but |
181
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
182
|
|
|
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
183
|
|
|
|
|
|
|
more details. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
186
|
|
|
|
|
|
|
Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |