| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Documentation::RequirePodAtEnd; |
|
2
|
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
26002
|
use 5.010001; |
|
|
40
|
|
|
|
|
165
|
|
|
4
|
40
|
|
|
40
|
|
380
|
use strict; |
|
|
40
|
|
|
|
|
116
|
|
|
|
40
|
|
|
|
|
856
|
|
|
5
|
40
|
|
|
40
|
|
192
|
use warnings; |
|
|
40
|
|
|
|
|
95
|
|
|
|
40
|
|
|
|
|
1125
|
|
|
6
|
40
|
|
|
40
|
|
249
|
use Readonly; |
|
|
40
|
|
|
|
|
125
|
|
|
|
40
|
|
|
|
|
2159
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
294
|
use List::Util qw(first); |
|
|
40
|
|
|
|
|
149
|
|
|
|
40
|
|
|
|
|
3018
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
40
|
|
|
40
|
|
299
|
use Perl::Critic::Utils qw{ :severities }; |
|
|
40
|
|
|
|
|
136
|
|
|
|
40
|
|
|
|
|
2007
|
|
|
11
|
40
|
|
|
40
|
|
5317
|
use parent 'Perl::Critic::Policy'; |
|
|
40
|
|
|
|
|
111
|
|
|
|
40
|
|
|
|
|
247
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '1.150'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Readonly::Scalar my $POD_RX => qr{\A = (?: for|begin|end ) }xms; |
|
18
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{POD before __END__}; |
|
19
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => [139, 140]; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
22
|
|
|
|
|
|
|
|
|
23
|
89
|
|
|
89
|
0
|
1624
|
sub supported_parameters { return () } |
|
24
|
76
|
|
|
76
|
1
|
315
|
sub default_severity { return $SEVERITY_LOWEST } |
|
25
|
84
|
|
|
84
|
1
|
329
|
sub default_themes { return qw( core cosmetic pbp ) } |
|
26
|
30
|
|
|
30
|
1
|
95
|
sub applies_to { return 'PPI::Document' } |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub violates { |
|
31
|
30
|
|
|
30
|
1
|
81
|
my ( $self, $elem, $doc ) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# No POD means no violation |
|
34
|
30
|
|
|
|
|
90
|
my $pods_ref = $doc->find('PPI::Token::Pod'); |
|
35
|
30
|
100
|
|
|
|
188
|
return if !$pods_ref; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Look for first POD tag that isn't =for, =begin, or =end |
|
38
|
2
|
|
|
2
|
|
12
|
my $pod = first { $_ !~ $POD_RX} @{ $pods_ref }; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
10
|
|
|
39
|
2
|
50
|
|
|
|
19
|
return if !$pod; |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
10
|
my $end = $doc->find_first('PPI::Statement::End'); |
|
42
|
2
|
50
|
|
|
|
9
|
if ($end) { # No __END__ means definite violation |
|
43
|
0
|
|
|
|
|
0
|
my $pod_loc = $pod->location(); |
|
44
|
0
|
|
|
|
|
0
|
my $end_loc = $end->location(); |
|
45
|
0
|
0
|
|
|
|
0
|
if ( $pod_loc->[0] > $end_loc->[0] ) { |
|
46
|
|
|
|
|
|
|
# POD is after __END__, or relative position couldn't be determined |
|
47
|
0
|
|
|
|
|
0
|
return; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
13
|
return $self->violation( $DESC, $EXPL, $pod ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=pod |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Perl::Critic::Policy::Documentation::RequirePodAtEnd - All POD should be after C<__END__>. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
|
70
|
|
|
|
|
|
|
distribution. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Perl stops processing code when it sees an C<__END__> statement. So, |
|
76
|
|
|
|
|
|
|
to save processing time, it's faster to put documentation after the |
|
77
|
|
|
|
|
|
|
C<__END__>. Also, writing all the POD in one place usually leads to a |
|
78
|
|
|
|
|
|
|
more cohesive document, rather than being forced to follow the layout |
|
79
|
|
|
|
|
|
|
of your code. This policy issues violations if any POD is found |
|
80
|
|
|
|
|
|
|
before an C<__END__>. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 CONFIGURATION |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NOTES |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Some folks like to use C<=for>, and C<=begin>, and C<=end> tags to |
|
91
|
|
|
|
|
|
|
create block comments in-line with their code. Since those tags |
|
92
|
|
|
|
|
|
|
aren't usually part of the documentation, this Policy does allows them |
|
93
|
|
|
|
|
|
|
to appear before the C<__END__> statement. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=begin comments |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
frobulate() |
|
98
|
|
|
|
|
|
|
Accepts: A list of things to frobulate |
|
99
|
|
|
|
|
|
|
Returns: True if successful |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=end comments |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub frobulate { ... } |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Chris Dolan <cdolan@cpan.org> |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (c) 2006-2011 Chris Dolan. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
115
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
|
116
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Local Variables: |
|
121
|
|
|
|
|
|
|
# mode: cperl |
|
122
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
|
123
|
|
|
|
|
|
|
# fill-column: 78 |
|
124
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
|
125
|
|
|
|
|
|
|
# c-indentation-style: bsd |
|
126
|
|
|
|
|
|
|
# End: |
|
127
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |