Login
RT #79289: False Postive in Perl::Critic::Utils::is_in_void_context()
[gknop/Perl-Critic.git] / inc / Perl / Critic / Module / Build.pm
CommitLineData
da2ead5e
ES
1#######################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6########################################################################
7
8package Perl::Critic::Module::Build;
9
10use 5.006001;
11
12use strict;
13use warnings;
46f91981 14
7f30e919 15our $VERSION = '1.116';
46f91981 16
8a8ef23d
ES
17use Carp;
18use English qw< $OS_ERROR $EXECUTABLE_NAME -no_match_vars >;
b11c430a 19
0a630832 20
91c348c8 21use base 'Perl::Critic::Module::Build::Standard';
da2ead5e 22
8a8ef23d 23
b005b12c
ES
24sub ACTION_policysummary {
25 my ($self) = @_;
26
b11c430a
ES
27 require Perl::Critic::PolicySummaryGenerator;
28 Perl::Critic::PolicySummaryGenerator->import(
29 qw< generate_policy_summary >
30 );
31
b005b12c
ES
32 my $policy_summary_file = generate_policy_summary();
33 $self->add_to_cleanup( $policy_summary_file );
34
35 return;
36}
37
38
8a8ef23d
ES
39sub ACTION_nytprof {
40 my ($self) = @_;
b005b12c 41
8a8ef23d
ES
42 $self->depends_on('build');
43 $self->_run_nytprof();
b005b12c 44
8a8ef23d
ES
45 return;
46}
47
48
91c348c8 49sub authortest_dependencies {
0b1167d5 50 my ($self) = @_;
b11c430a 51
b005b12c 52 $self->depends_on('policysummary');
91c348c8 53 $self->SUPER::authortest_dependencies();
506d38ff
ES
54
55 return;
56}
57
58
8a8ef23d
ES
59sub _run_nytprof {
60 my ($self) = @_;
61
b11c430a
ES
62 eval { require Devel::NYTProf; 1 }
63 or croak 'Devel::NYTProf is required to run nytprof';
8a8ef23d 64
b11c430a
ES
65 eval { require File::Which; File::Which->import('which'); 1 }
66 or croak 'File::Which is required to run nytprof';
8a8ef23d
ES
67
68 my $nytprofhtml = which('nytprofhtml')
b11c430a 69 or croak 'Could not find nytprofhtml in your PATH';
8a8ef23d
ES
70
71 my $this_perl = $EXECUTABLE_NAME;
72 my @perl_args = qw(-Iblib/lib -d:NYTProf blib/script/perlcritic);
b11c430a
ES
73 my @perlcritic_args =
74 qw<
75 --noprofile
76 --severity=1
77 --theme=core
78 --exclude=TidyCode
79 --exclude=PodSpelling
80 blib
81 >;
82 warn "Running: $this_perl @perl_args @perlcritic_args\n";
8a8ef23d
ES
83
84 my $status_perlcritic = system $this_perl, @perl_args, @perlcritic_args;
b11c430a
ES
85 croak "perlcritic failed with status $status_perlcritic"
86 if $status_perlcritic == 1;
8a8ef23d
ES
87
88 my $status_nytprofhtml = system $nytprofhtml;
b11c430a
ES
89 croak "nytprofhtml failed with status $status_nytprofhtml"
90 if $status_nytprofhtml;
8a8ef23d
ES
91
92 return;
93}
94
b005b12c 95
da2ead5e
ES
961;
97
98
99__END__
100
101#-----------------------------------------------------------------------------
102
103=pod
104
105=for stopwords
106
107=head1 NAME
108
109Perl::Critic::Module::Build - Customization of L<Module::Build> for L<Perl::Critic>.
110
111
112=head1 DESCRIPTION
113
91c348c8
ES
114This is a custom subclass of L<Module::Build> (actually,
115L<Perl::Critic::Module::Build::Standard>) that enhances existing functionality
116and adds more for the benefit of installing and developing L<Perl::Critic>.
117The following actions have been added or redefined:
da2ead5e
ES
118
119
b005b12c 120=head1 ACTIONS
da2ead5e
ES
121
122=over
123
b005b12c
ES
124=item policysummary
125
126Generates the F<PolicySummary.pod> file. This should only be used by
127C<Perl::Critic> developers. This action is also invoked by the C<authortest>
128action, so the F<PolicySummary.pod> file will be generated whenever you create
129a distribution with the C<dist> or C<distdir> targets.
130
131
132=item nytprof
8a8ef23d
ES
133
134Runs perlcritic under the L<Devel::NYTProf> profiler and generates
135an HTML report in F<nytprof/index.html>.
136
da2ead5e
ES
137
138=back
139
140
141=head1 AUTHOR
142
143Elliot Shank <perl@galumph.com>
144
145=head1 COPYRIGHT
146
53b8903f 147Copyright (c) 2007-2011 Elliot Shank.
da2ead5e
ES
148
149This program is free software; you can redistribute it and/or modify
150it under the same terms as Perl itself. The full text of this license
151can be found in the LICENSE file included with this module.
152
153=cut
154
155
156##############################################################################
157# Local Variables:
158# mode: cperl
159# cperl-indent-level: 4
160# fill-column: 78
161# indent-tabs-mode: nil
162# c-indentation-style: bsd
163# End:
164# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :