| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 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
|
|
|
|
|
|
|
# perlcritic -s RequireFilenameMarkup RequireFilenameMarkup.pm |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# unmarked /usr/local |
|
22
|
|
|
|
|
|
|
# perlcritic -s RequireFilenameMarkup /usr/share/perl5/XML/Twig.pm |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Perl::Critic::Policy::Documentation::RequireFilenameMarkup; |
|
26
|
40
|
|
|
40
|
|
33583
|
use 5.006; |
|
|
40
|
|
|
|
|
157
|
|
|
27
|
40
|
|
|
40
|
|
240
|
use strict; |
|
|
40
|
|
|
|
|
99
|
|
|
|
40
|
|
|
|
|
848
|
|
|
28
|
40
|
|
|
40
|
|
216
|
use warnings; |
|
|
40
|
|
|
|
|
91
|
|
|
|
40
|
|
|
|
|
1124
|
|
|
29
|
40
|
|
|
40
|
|
226
|
use base 'Perl::Critic::Policy'; |
|
|
40
|
|
|
|
|
93
|
|
|
|
40
|
|
|
|
|
4976
|
|
|
30
|
40
|
|
|
40
|
|
183168
|
use Perl::Critic::Utils; |
|
|
40
|
|
|
|
|
131
|
|
|
|
40
|
|
|
|
|
789
|
|
|
31
|
40
|
|
|
40
|
|
58692
|
use Pod::Escapes; |
|
|
40
|
|
|
|
|
139153
|
|
|
|
40
|
|
|
|
|
4097
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
|
34
|
|
|
|
|
|
|
# use Smart::Comments; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
our $VERSION = 99; |
|
37
|
|
|
|
|
|
|
|
|
38
|
40
|
|
|
40
|
|
361
|
use constant supported_parameters => (); |
|
|
40
|
|
|
|
|
103
|
|
|
|
40
|
|
|
|
|
2872
|
|
|
39
|
40
|
|
|
40
|
|
272
|
use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOW; |
|
|
40
|
|
|
|
|
93
|
|
|
|
40
|
|
|
|
|
2246
|
|
|
40
|
40
|
|
|
40
|
|
248
|
use constant default_themes => qw(pulp cosmetic); |
|
|
40
|
|
|
|
|
88
|
|
|
|
40
|
|
|
|
|
2190
|
|
|
41
|
40
|
|
|
40
|
|
252
|
use constant applies_to => 'PPI::Document'; |
|
|
40
|
|
|
|
|
83
|
|
|
|
40
|
|
|
|
|
5249
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub violates { |
|
44
|
41
|
|
|
41
|
1
|
595646
|
my ($self, $elem, $document) = @_; |
|
45
|
|
|
|
|
|
|
### RequireFilenameMarkup on: $elem->content |
|
46
|
|
|
|
|
|
|
|
|
47
|
41
|
|
|
|
|
579
|
my $parser = Perl::Critic::Pulp::PodParser::RequireFilenameMarkup->new |
|
48
|
|
|
|
|
|
|
(policy => $self); |
|
49
|
41
|
|
|
|
|
213
|
$parser->parse_from_elem ($elem); |
|
50
|
41
|
|
|
|
|
308
|
return $parser->violations; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
package Perl::Critic::Pulp::PodParser::RequireFilenameMarkup; |
|
54
|
40
|
|
|
40
|
|
370
|
use strict; |
|
|
40
|
|
|
|
|
108
|
|
|
|
40
|
|
|
|
|
1054
|
|
|
55
|
40
|
|
|
40
|
|
215
|
use warnings; |
|
|
40
|
|
|
|
|
105
|
|
|
|
40
|
|
|
|
|
1392
|
|
|
56
|
40
|
|
|
40
|
|
759
|
use Pod::ParseLink; |
|
|
40
|
|
|
|
|
999
|
|
|
|
40
|
|
|
|
|
2066
|
|
|
57
|
40
|
|
|
40
|
|
279
|
use base 'Perl::Critic::Pulp::PodParser'; |
|
|
40
|
|
|
|
|
88
|
|
|
|
40
|
|
|
|
|
25325
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub command { |
|
60
|
41
|
|
|
41
|
|
3896
|
my $self = shift; |
|
61
|
41
|
|
|
|
|
214
|
$self->SUPER::command(@_); # for $self->{'in_begin'} |
|
62
|
41
|
|
|
|
|
170
|
$self->command_as_textblock(@_); |
|
63
|
41
|
|
|
|
|
597
|
return ''; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub textblock { |
|
67
|
79
|
|
|
79
|
|
2806
|
my ($self, $text, $linenum, $pod_para) = @_; |
|
68
|
|
|
|
|
|
|
### textblock: "linenum=$linenum" |
|
69
|
|
|
|
|
|
|
|
|
70
|
79
|
50
|
50
|
|
|
430
|
if (($self->{'allow_next'}||0) > 0) { |
|
71
|
0
|
|
|
|
|
0
|
$self->{'allow_next'}--; |
|
72
|
0
|
|
|
|
|
0
|
return ''; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# process outside =begin, and inside =begin which is ":" markup |
|
76
|
79
|
50
|
33
|
|
|
275
|
unless ($self->{'in_begin'} eq '' || $self->{'in_begin'} =~ /^:/) { |
|
77
|
0
|
|
|
|
|
0
|
return ''; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
79
|
|
|
|
|
4113
|
my $interpolated = $self->interpolate($text, $linenum); |
|
81
|
|
|
|
|
|
|
### $text |
|
82
|
|
|
|
|
|
|
### $interpolated |
|
83
|
|
|
|
|
|
|
|
|
84
|
79
|
|
|
|
|
876
|
while ($interpolated =~ m{(^ | (?<=[\([:space:]])) # BOL or preceding space |
|
85
|
|
|
|
|
|
|
( |
|
86
|
|
|
|
|
|
|
/(bin|etc|dev|opt|proc|tmp|usr|var) |
|
87
|
|
|
|
|
|
|
($ # EOL |
|
88
|
|
|
|
|
|
|
|(?=[)[:space:]]) # or following space |
|
89
|
|
|
|
|
|
|
|/\S*) # or /chars |
|
90
|
|
|
|
|
|
|
| |
|
91
|
|
|
|
|
|
|
[cC]:\\\S* |
|
92
|
|
|
|
|
|
|
) |
|
93
|
|
|
|
|
|
|
}mgx) { |
|
94
|
36
|
|
|
|
|
108
|
my $before = $1; |
|
95
|
36
|
|
|
|
|
81
|
my $match = $2; |
|
96
|
36
|
|
|
|
|
109
|
$match =~ s/[.,;:]+$//; |
|
97
|
36
|
|
|
|
|
85
|
my $pos = pos($interpolated) - length($match); |
|
98
|
|
|
|
|
|
|
|
|
99
|
36
|
|
|
|
|
216
|
$self->violation_at_linenum_and_textpos |
|
100
|
|
|
|
|
|
|
("Filename without F<> or other markup \"$match\"\n", |
|
101
|
|
|
|
|
|
|
$linenum, $interpolated, $pos); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub interior_sequence { |
|
106
|
12
|
|
|
12
|
|
53
|
my ($self, $cmd, $text, $pod_seq) = @_; |
|
107
|
|
|
|
|
|
|
### $cmd |
|
108
|
|
|
|
|
|
|
### $text |
|
109
|
|
|
|
|
|
|
|
|
110
|
12
|
100
|
|
|
|
42
|
if ($cmd eq 'E') { |
|
111
|
3
|
|
|
|
|
13
|
my $char = Pod::Escapes::e2char($text); |
|
112
|
3
|
50
|
|
|
|
48
|
if (! defined $char) { |
|
113
|
|
|
|
|
|
|
### oops, unrecognised E<> ... |
|
114
|
0
|
|
|
|
|
0
|
return 'X'; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
3
|
|
|
|
|
153
|
return $char; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
9
|
100
|
|
|
|
28
|
if ($cmd eq 'L') { |
|
119
|
5
|
|
|
|
|
21
|
my ($display, $inferred, $name, $section, $type) |
|
120
|
|
|
|
|
|
|
= Pod::ParseLink::parselink ($text); |
|
121
|
|
|
|
|
|
|
### $display |
|
122
|
|
|
|
|
|
|
### $inferred |
|
123
|
|
|
|
|
|
|
### $name |
|
124
|
5
|
|
|
|
|
263
|
return $inferred; # the display part, or the name part if no display |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
### X,C keep only the newlines: $text |
|
128
|
4
|
|
|
|
|
11
|
$text =~ tr/\n//cd; |
|
129
|
4
|
|
|
|
|
136
|
return $text; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
__END__ |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=for stopwords Ryde filenames filename Filenames |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 NAME |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Perl::Critic::Policy::Documentation::RequireFilenameMarkup - markup /foo filenames |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This policy is part of the L<C<Perl::Critic::Pulp>|Perl::Critic::Pulp> |
|
144
|
|
|
|
|
|
|
add-on. It asks you to use C<FE<lt>E<gt>> or other markup on filenames. |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=for ProhibitVerbatimMarkup allow next 2 |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
/usr/bin # bad |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
F</usr/bin> # ok |
|
151
|
|
|
|
|
|
|
C</bin/sh> # ok |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
C<FE<lt>E<gt>> lets the formatters show filenames in a usual way, such as |
|
154
|
|
|
|
|
|
|
italics in man pages. This can help human readability but is a minor matter |
|
155
|
|
|
|
|
|
|
and on that basis this policy is lowest severity and under the "cosmetic" |
|
156
|
|
|
|
|
|
|
theme (see L<Perl::Critic/POLICY THEMES>). |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Filenames in text are identified by likely forms. Currently words starting |
|
159
|
|
|
|
|
|
|
as follows are considered filenames. F</usr> and F</etc> are the most |
|
160
|
|
|
|
|
|
|
common. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
/bin |
|
163
|
|
|
|
|
|
|
/dev |
|
164
|
|
|
|
|
|
|
/etc |
|
165
|
|
|
|
|
|
|
/opt # some proprietary Unix |
|
166
|
|
|
|
|
|
|
/proc |
|
167
|
|
|
|
|
|
|
/tmp |
|
168
|
|
|
|
|
|
|
/usr |
|
169
|
|
|
|
|
|
|
/var |
|
170
|
|
|
|
|
|
|
C:\ # MS-DOS |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Any markup on a filename satisfies this policy. C<FE<lt>E<gt>> is usual, |
|
173
|
|
|
|
|
|
|
but C<CE<lt>E<gt>> might suit for instance C<CE<lt>/bin/shE<gt>> to show |
|
174
|
|
|
|
|
|
|
it's a command with path rather than a file as such. |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
C<=begin :foo> blocks with <:> POD type are checked since they can have |
|
177
|
|
|
|
|
|
|
markup. "Verbatim" paragraphs are ignored since of course they cannot have |
|
178
|
|
|
|
|
|
|
markup. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head2 Disabling |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
If you don't care about filename markup you can disable |
|
183
|
|
|
|
|
|
|
C<RequireFilenameMarkup> from your F<.perlcriticrc> in the usual way (see |
|
184
|
|
|
|
|
|
|
L<Perl::Critic/CONFIGURATION>), |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
[-Documentation::RequireFilenameMarkup] |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
L<Perl::Critic::Pulp>, |
|
191
|
|
|
|
|
|
|
L<Perl::Critic> |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 HOME PAGE |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
L<http://user42.tuxfamily.org/perl-critic-pulp/index.html> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Copyright 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Perl-Critic-Pulp is free software; you can redistribute it and/or modify it |
|
202
|
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the Free |
|
203
|
|
|
|
|
|
|
Software Foundation; either version 3, or (at your option) any later |
|
204
|
|
|
|
|
|
|
version. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Perl-Critic-Pulp is distributed in the hope that it will be useful, but |
|
207
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
208
|
|
|
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|
209
|
|
|
|
|
|
|
more details. |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
212
|
|
|
|
|
|
|
Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>. |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# /usr/local |
|
217
|
|
|
|
|
|
|
# /opt. |
|
218
|
|
|
|
|
|
|
# /tmp |
|
219
|
|
|
|
|
|
|
# /dev/null |
|
220
|
|
|
|
|
|
|
# /dev/ |
|
221
|
|
|
|
|
|
|
# /dev. |
|
222
|
|
|
|
|
|
|
# blah/option |
|
223
|
|
|
|
|
|
|
# |
|
224
|
|
|
|
|
|
|
# /option |
|
225
|
|
|
|
|
|
|
# |
|
226
|
|
|
|
|
|
|
# blah/blah/etc |
|
227
|
|
|
|
|
|
|
# |
|
228
|
|
|
|
|
|
|
# E<sol>dev |