| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::GitHooks::Plugin::ValidatePODFormat; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
2411718
|
use strict; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
363
|
|
|
4
|
9
|
|
|
9
|
|
50
|
use warnings; |
|
|
9
|
|
|
|
|
19
|
|
|
|
9
|
|
|
|
|
301
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
9
|
|
|
9
|
|
48
|
use base 'App::GitHooks::Plugin'; |
|
|
9
|
|
|
|
|
56
|
|
|
|
9
|
|
|
|
|
3768
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# External dependencies. |
|
9
|
9
|
|
|
9
|
|
11850
|
use Pod::Simple; |
|
|
9
|
|
|
|
|
329834
|
|
|
|
9
|
|
|
|
|
477
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Internal dependencies. |
|
12
|
9
|
|
|
9
|
|
3702
|
use App::GitHooks::Constants qw( :PLUGIN_RETURN_CODES ); |
|
|
9
|
|
|
|
|
1018
|
|
|
|
9
|
|
|
|
|
5513
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
App::GitHooks::Plugin::ValidatePODFormat - Validate POD format in Perl and POD files. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 VERSION |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Version 1.0.1 |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=cut |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our $VERSION = '1.0.1'; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 get_file_pattern() |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Return a pattern to filter the files this plugin should analyze. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $file_pattern = App::GitHooks::Plugin::ValidatePODFormat->get_file_pattern( |
|
39
|
|
|
|
|
|
|
app => $app, |
|
40
|
|
|
|
|
|
|
); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_file_pattern |
|
45
|
|
|
|
|
|
|
{ |
|
46
|
7
|
|
|
7
|
1
|
1233754
|
return qr/\.(?:pl|pm|t|cgi|pod)$/x; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 get_file_check_description() |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Return a description of the check performed on files by the plugin and that |
|
53
|
|
|
|
|
|
|
will be displayed to the user, if applicable, along with an indication of the |
|
54
|
|
|
|
|
|
|
success or failure of the plugin. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $description = App::GitHooks::Plugin::ValidatePODFormat->get_file_check_description(); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get_file_check_description |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
7
|
|
|
7
|
1
|
13067
|
return 'POD format is valid.'; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 run_pre_commit_file() |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Code to execute for each file as part of the pre-commit hook. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $success = App::GitHooks::Plugin::ValidatePODFormat->run_pre_commit_file(); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub run_pre_commit_file |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
3
|
|
|
3
|
1
|
10898
|
my ( $class, %args ) = @_; |
|
77
|
3
|
|
|
|
|
110
|
my $file = delete( $args{'file'} ); |
|
78
|
3
|
|
|
|
|
102
|
my $git_action = delete( $args{'git_action'} ); |
|
79
|
3
|
|
|
|
|
30
|
my $app = delete( $args{'app'} ); |
|
80
|
3
|
|
|
|
|
409
|
my $staged_changes = $app->get_staged_changes(); |
|
81
|
3
|
|
|
|
|
175
|
my $repository = $app->get_repository(); |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Ignore deleted files. |
|
84
|
3
|
50
|
|
|
|
105
|
return $PLUGIN_RETURN_SKIPPED |
|
85
|
|
|
|
|
|
|
if $git_action eq 'D'; |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Ignore revert commits. |
|
88
|
3
|
50
|
|
|
|
166
|
return $PLUGIN_RETURN_SKIPPED |
|
89
|
|
|
|
|
|
|
if $staged_changes->is_revert(); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Run the POD checker. |
|
92
|
3
|
|
|
|
|
786
|
my $checker = Pod::Simple->new(); |
|
93
|
3
|
|
|
|
|
1312
|
$checker->output_string( \my $trash ); # Ignore any output |
|
94
|
3
|
|
|
|
|
21716
|
$checker->parse_file( $file ); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# If the POD checker reports an error, investigate. |
|
97
|
3
|
100
|
|
|
|
3801
|
if ( $checker->any_errata_seen() ) { |
|
98
|
|
|
|
|
|
|
# Parse the errors. |
|
99
|
1
|
|
|
|
|
11
|
my @formatted_errors = (); |
|
100
|
1
|
|
|
|
|
3
|
my $lines = $checker->{errata}; |
|
101
|
1
|
|
|
|
|
11
|
foreach my $line ( sort { $a <=> $b } keys %$lines ) { |
|
|
0
|
|
|
|
|
0
|
|
|
102
|
1
|
|
|
|
|
3
|
my $errors = $lines->{$line}; |
|
103
|
1
|
|
|
|
|
2
|
push( @formatted_errors, map { "Line $line: $_" } @$errors ); |
|
|
1
|
|
|
|
|
6
|
|
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# An error was reported but no specific error was found. This shouldn't |
|
107
|
|
|
|
|
|
|
# happen. |
|
108
|
1
|
50
|
|
|
|
5
|
die "POD parsing failed, but no specific error could be reported.\n" |
|
109
|
|
|
|
|
|
|
if scalar( @formatted_errors ) == 0; |
|
110
|
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
65
|
die join( "\n", @formatted_errors ), "\n"; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
150
|
return $PLUGIN_RETURN_PASSED; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 BUGS |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
|
121
|
|
|
|
|
|
|
L. |
|
122
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
123
|
|
|
|
|
|
|
your bug as I make changes. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SUPPORT |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
perldoc App::GitHooks::ValidatePODFormat |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You can also look for information at: |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=over |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * GitHub's request tracker |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * MetaCPAN |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L, |
|
159
|
|
|
|
|
|
|
C<< >>. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright 2013-2014 Guillaume Aubert. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under |
|
167
|
|
|
|
|
|
|
the terms of the GNU General Public License version 3 as published by the Free |
|
168
|
|
|
|
|
|
|
Software Foundation. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
|
171
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
172
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
|
175
|
|
|
|
|
|
|
this program. If not, see http://www.gnu.org/licenses/ |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; |