line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2736709
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Test::Perl::Critic; # git description: v3.000-10-gfceb71d |
6
|
|
|
|
|
|
|
# ABSTRACT: Tests to check your code against best practices |
7
|
|
|
|
|
|
|
our $VERSION = '3.001'; |
8
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
9
|
1
|
|
|
1
|
|
6026
|
use Moose::Util qw( get_all_attribute_values ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
707
|
use Dist::Zilla::File::InMemory; |
|
1
|
|
|
|
|
78312
|
|
|
1
|
|
|
|
|
40
|
|
12
|
1
|
|
|
1
|
|
10
|
use Sub::Exporter::ForMethods 'method_installer'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
13
|
1
|
|
|
1
|
|
313
|
use Data::Section 0.004 { installer => method_installer }, '-setup'; |
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
8
|
|
14
|
1
|
|
|
1
|
|
761
|
use namespace::autoclean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# and when the time comes, treat them like templates |
17
|
|
|
|
|
|
|
with qw( |
18
|
|
|
|
|
|
|
Dist::Zilla::Role::FileGatherer |
19
|
|
|
|
|
|
|
Dist::Zilla::Role::TextTemplate |
20
|
|
|
|
|
|
|
Dist::Zilla::Role::PrereqSource |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has critic_config => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
26
|
|
|
|
|
|
|
default => 'perlcritic.rc', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub gather_files { |
30
|
4
|
|
|
4
|
0
|
89094
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
4
|
|
|
|
|
26
|
my $data = $self->merged_section_data; |
33
|
4
|
50
|
33
|
|
|
853
|
return unless $data and %$data; |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
|
|
20
|
my $stash = get_all_attribute_values( $self->meta, $self); |
36
|
4
|
|
100
|
|
|
2962
|
$stash->{critic_config} ||= 'perlcritic.rc'; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# NB: This code is a bit generalised really, and could be forked into its |
39
|
|
|
|
|
|
|
# own plugin. |
40
|
4
|
|
|
|
|
19
|
for my $name ( keys %$data ){ |
41
|
4
|
|
|
|
|
9
|
my $template = ${$data->{$name}}; |
|
4
|
|
|
|
|
12
|
|
42
|
4
|
|
|
|
|
29
|
$self->add_file( Dist::Zilla::File::InMemory->new({ |
43
|
|
|
|
|
|
|
name => $name, |
44
|
|
|
|
|
|
|
content => $self->fill_in_string( $template, $stash ) |
45
|
|
|
|
|
|
|
})); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub register_prereqs { |
50
|
4
|
|
|
4
|
0
|
16596
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
4
|
|
|
|
|
103
|
$self->zilla->register_prereqs( |
53
|
|
|
|
|
|
|
{ |
54
|
|
|
|
|
|
|
type => 'requires', |
55
|
|
|
|
|
|
|
phase => 'develop', |
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
'Test::Perl::Critic' => 0, |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# TODO also extract list of policies used in file $self->critic_config |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
|
263
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
64
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
#pod =pod |
67
|
|
|
|
|
|
|
#pod |
68
|
|
|
|
|
|
|
#pod =for Pod::Coverage gather_files register_prereqs |
69
|
|
|
|
|
|
|
#pod |
70
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
71
|
|
|
|
|
|
|
#pod |
72
|
|
|
|
|
|
|
#pod In your F<dist.ini>: |
73
|
|
|
|
|
|
|
#pod |
74
|
|
|
|
|
|
|
#pod [Test::Perl::Critic] |
75
|
|
|
|
|
|
|
#pod critic_config = perlcritic.rc ; default / relative to project root |
76
|
|
|
|
|
|
|
#pod |
77
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
78
|
|
|
|
|
|
|
#pod |
79
|
|
|
|
|
|
|
#pod This will provide a F<t/author/critic.t> file for use during the "test" and |
80
|
|
|
|
|
|
|
#pod "release" calls of C<dzil>. To use this, make the changes to F<dist.ini> |
81
|
|
|
|
|
|
|
#pod above and run one of the following: |
82
|
|
|
|
|
|
|
#pod |
83
|
|
|
|
|
|
|
#pod dzil test |
84
|
|
|
|
|
|
|
#pod dzil release |
85
|
|
|
|
|
|
|
#pod |
86
|
|
|
|
|
|
|
#pod During these runs, F<t/author/critic.t> will use L<Test::Perl::Critic> to run |
87
|
|
|
|
|
|
|
#pod L<Perl::Critic> against your code and by report findings. |
88
|
|
|
|
|
|
|
#pod |
89
|
|
|
|
|
|
|
#pod This plugin accepts the C<critic_config> option, which specifies your own config |
90
|
|
|
|
|
|
|
#pod file for L<Perl::Critic>. It defaults to C<perlcritic.rc>, relative to the |
91
|
|
|
|
|
|
|
#pod project root. If the file does not exist, L<Perl::Critic> will use its defaults. |
92
|
|
|
|
|
|
|
#pod |
93
|
|
|
|
|
|
|
#pod This plugin is an extension of L<Dist::Zilla::Plugin::InlineFiles>. |
94
|
|
|
|
|
|
|
#pod |
95
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
96
|
|
|
|
|
|
|
#pod |
97
|
|
|
|
|
|
|
#pod You can look for information on this module at: |
98
|
|
|
|
|
|
|
#pod |
99
|
|
|
|
|
|
|
#pod =for stopwords AnnoCPAN |
100
|
|
|
|
|
|
|
#pod |
101
|
|
|
|
|
|
|
#pod =over 4 |
102
|
|
|
|
|
|
|
#pod |
103
|
|
|
|
|
|
|
#pod =item * Search CPAN |
104
|
|
|
|
|
|
|
#pod |
105
|
|
|
|
|
|
|
#pod L<http://search.cpan.org/dist/Dist-Zilla-Plugin-Test-Perl-Critic> |
106
|
|
|
|
|
|
|
#pod |
107
|
|
|
|
|
|
|
#pod =item * See open / report bugs |
108
|
|
|
|
|
|
|
#pod |
109
|
|
|
|
|
|
|
#pod L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dist-Zilla-Plugin-Test-Perl-Critic> |
110
|
|
|
|
|
|
|
#pod |
111
|
|
|
|
|
|
|
#pod =item * Mailing-list (same as L<Dist::Zilla>) |
112
|
|
|
|
|
|
|
#pod |
113
|
|
|
|
|
|
|
#pod L<http://www.listbox.com/subscribe/?list_id=139292> |
114
|
|
|
|
|
|
|
#pod |
115
|
|
|
|
|
|
|
#pod =item * Git repository |
116
|
|
|
|
|
|
|
#pod |
117
|
|
|
|
|
|
|
#pod L<http://github.com/jquelin/dist-zilla-plugin-test-perl-critic> |
118
|
|
|
|
|
|
|
#pod |
119
|
|
|
|
|
|
|
#pod =item * AnnoCPAN: Annotated CPAN documentation |
120
|
|
|
|
|
|
|
#pod |
121
|
|
|
|
|
|
|
#pod L<http://annocpan.org/dist/Dist-Zilla-Plugin-Test-Perl-Critic> |
122
|
|
|
|
|
|
|
#pod |
123
|
|
|
|
|
|
|
#pod =item * CPAN Ratings |
124
|
|
|
|
|
|
|
#pod |
125
|
|
|
|
|
|
|
#pod L<http://cpanratings.perl.org/d/Dist-Zilla-Plugin-Test-Perl-Critic> |
126
|
|
|
|
|
|
|
#pod |
127
|
|
|
|
|
|
|
#pod =back |
128
|
|
|
|
|
|
|
#pod |
129
|
|
|
|
|
|
|
#pod =cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=pod |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=encoding UTF-8 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 NAME |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Test::Perl::Critic - Tests to check your code against best practices |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 VERSION |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
version 3.001 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SYNOPSIS |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
In your F<dist.ini>: |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
[Test::Perl::Critic] |
148
|
|
|
|
|
|
|
critic_config = perlcritic.rc ; default / relative to project root |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This will provide a F<t/author/critic.t> file for use during the "test" and |
153
|
|
|
|
|
|
|
"release" calls of C<dzil>. To use this, make the changes to F<dist.ini> |
154
|
|
|
|
|
|
|
above and run one of the following: |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
dzil test |
157
|
|
|
|
|
|
|
dzil release |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
During these runs, F<t/author/critic.t> will use L<Test::Perl::Critic> to run |
160
|
|
|
|
|
|
|
L<Perl::Critic> against your code and by report findings. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This plugin accepts the C<critic_config> option, which specifies your own config |
163
|
|
|
|
|
|
|
file for L<Perl::Critic>. It defaults to C<perlcritic.rc>, relative to the |
164
|
|
|
|
|
|
|
project root. If the file does not exist, L<Perl::Critic> will use its defaults. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This plugin is an extension of L<Dist::Zilla::Plugin::InlineFiles>. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=for Pod::Coverage gather_files register_prereqs |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 SEE ALSO |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
You can look for information on this module at: |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=for stopwords AnnoCPAN |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=over 4 |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * Search CPAN |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Dist-Zilla-Plugin-Test-Perl-Critic> |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * See open / report bugs |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Dist-Zilla-Plugin-Test-Perl-Critic> |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * Mailing-list (same as L<Dist::Zilla>) |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
L<http://www.listbox.com/subscribe/?list_id=139292> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * Git repository |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L<http://github.com/jquelin/dist-zilla-plugin-test-perl-critic> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Dist-Zilla-Plugin-Test-Perl-Critic> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * CPAN Ratings |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Dist-Zilla-Plugin-Test-Perl-Critic> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=back |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 SUPPORT |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Test-Perl-Critic> |
207
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-Test-Perl-Critic@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Test-Perl-Critic@rt.cpan.org>). |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
210
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
213
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 AUTHOR |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
Jerome Quelin |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=for stopwords Jérôme Quelin Karen Etheridge Kent Fredric Olivier Mengué Stephen R. Scaffidi Gryphon Shafer Mike Doherty |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=over 4 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Jérôme Quelin <jquelin@gmail.com> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Kent Fredric <kentfredric@gmail.com> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Olivier Mengué <dolmen@cpan.org> |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item * |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Stephen R. Scaffidi <stephen@scaffidi.net> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item * |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Gryphon Shafer <gryphon@goldenguru.com> |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item * |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Mike Doherty <doherty@cs.dal.ca> |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=back |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Jerome Quelin. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
260
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
__DATA__ |
265
|
|
|
|
|
|
|
___[ xt/author/critic.t ]___ |
266
|
|
|
|
|
|
|
#!perl |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
use strict; |
269
|
|
|
|
|
|
|
use warnings; |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
use Test::Perl::Critic (-profile => "{{ $critic_config }}") x!! -e "{{ $critic_config }}"; |
272
|
|
|
|
|
|
|
all_critic_ok(); |