Login
RT #77510: Left curlys as literals in regexps are deprecated.
[gknop/Perl-Critic.git] / inc / Perl / Critic / BuildUtilities.pm
CommitLineData
34cc6052
ES
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::BuildUtilities;
9
df6dee2b 10use 5.006001;
34cc6052
ES
11use strict;
12use warnings;
13
7963ad6d 14use English q<-no_match_vars>;
70f3f307 15
7f30e919 16our $VERSION = '1.116';
34cc6052
ES
17
18use base qw{ Exporter };
19
496afbe0 20our @EXPORT_OK = qw<
26dc721f
ES
21 required_module_versions
22 build_required_module_versions
70f3f307
ES
23 recommended_module_versions
24 test_wrappers_to_generate
496afbe0 25 get_PL_files
70f3f307 26 dump_unlisted_or_optional_module_versions
7963ad6d 27 emit_tar_warning_if_necessary
496afbe0
ES
28>;
29
30
7963ad6d
ES
31use Devel::CheckOS qw< os_is >;
32
34cc6052 33
26dc721f
ES
34sub required_module_versions {
35 return (
45ebc156
ES
36 'B::Keywords' => 1.05,
37 'Carp' => 0,
38 'Config::Tiny' => 2,
08baee8f 39 'Email::Address' => 1.889,
45ebc156
ES
40 'English' => 0,
41 'Exception::Class' => 1.23,
a7a5dcba 42 'Exporter' => 5.63,
45ebc156
ES
43 'File::Basename' => 0,
44 'File::Find' => 0,
45 'File::Path' => 0,
46 'File::Spec' => 0,
47 'File::Spec::Unix' => 0,
48 'File::Temp' => 0,
49 'Getopt::Long' => 0,
50 'IO::String' => 0,
be203e50 51 'IPC::Open2' => 1,
45ebc156
ES
52 'List::MoreUtils' => 0.19,
53 'List::Util' => 0,
54 'Module::Pluggable' => 3.1,
45a557b1
TW
55 'PPI' => '1.215', # RT 61301
56 'PPI::Document' => '1.215',
57 'PPI::Document::File' => '1.215',
58 'PPI::Node' => '1.215',
59 'PPI::Token::Quote::Single' => '1.215',
60 'PPI::Token::Whitespace' => '1.215',
7a52e1ec 61 'PPIx::Regexp' => '0.027', # Literal { deprecated in re
d6893a94
ES
62 'PPIx::Utilities::Node' => '1.001',
63 'PPIx::Utilities::Statement' => '1.001',
776c9cd4 64 'Perl::Tidy' => 0,
b11b1193 65 'Pod::Parser' => 0,
45ebc156
ES
66 'Pod::PlainText' => 0,
67 'Pod::Select' => 0,
776c9cd4 68 'Pod::Spell' => 1,
45ebc156
ES
69 'Pod::Usage' => 0,
70 'Readonly' => 1.03,
71 'Scalar::Util' => 0,
72 'String::Format' => 1.13,
ad421603 73 'Task::Weaken' => 0,
45ebc156 74 'Test::Builder' => 0.92,
776c9cd4 75 'Text::ParseWords' => 3,
45ebc156
ES
76 'base' => 0,
77 'charnames' => 0,
78 'overload' => 0,
79 'strict' => 0,
1e54fca6 80 'version' => 0.77,
45ebc156 81 'warnings' => 0,
26dc721f
ES
82 );
83}
84
85
86sub build_required_module_versions {
87 return (
88 'lib' => 0,
a9ce4c58 89 'Test::Deep' => 0,
26dc721f
ES
90 'Test::More' => 0,
91 );
92}
93
94
34cc6052
ES
95sub recommended_module_versions {
96 return (
97 'File::HomeDir' => 0,
eb6e0777 98 'Readonly::XS' => 0,
bf14ed6c
ES
99
100 # If the following changes, the corresponding change needs to be made
26185e38 101 # in $Perl::Critic::Utils::Constants::_MODULE_VERSION_TERM_ANSICOLOR.
bf14ed6c 102 'Term::ANSIColor' => '2.02',
34cc6052
ES
103
104 # All of these are for Documentation::PodSpelling
105 'File::Which' => 0,
34cc6052
ES
106 );
107}
108
496afbe0 109
34cc6052 110sub test_wrappers_to_generate {
70f3f307 111 my @tests_to_be_wrapped = qw<
34cc6052
ES
112 t/00_modules.t
113 t/01_config.t
114 t/01_config_bad_perlcriticrc.t
2798ab37 115 t/01_policy_config.t
34cc6052
ES
116 t/02_policy.t
117 t/03_pragmas.t
34c9f396 118 t/04_options_processor.t
34cc6052
ES
119 t/05_utils.t
120 t/05_utils_ppi.t
0d512192 121 t/05_utils_pod.t
34cc6052 122 t/06_violation.t
2560297d 123 t/07_command.t
34cc6052
ES
124 t/07_perlcritic.t
125 t/08_document.t
126 t/09_theme.t
34c9f396
JRT
127 t/10_user_profile.t
128 t/11_policy_factory.t
129 t/12_policy_listing.t
130 t/12_theme_listing.t
34cc6052
ES
131 t/13_bundled_policies.t
132 t/14_policy_parameters.t
133 t/15_statistics.t
2a6eef29 134 t/20_policies.t
492ab247 135 t/20_policy_pod_spelling.t
6a181acf
ES
136 t/20_policy_prohibit_evil_modules.t
137 t/20_policy_prohibit_hard_tabs.t
138 t/20_policy_prohibit_trailing_whitespace.t
139 t/20_policy_require_consistent_newlines.t
492ab247 140 t/20_policy_require_tidy_code.t
0d512192 141 xt/author/80_policysummary.t
34cc6052 142 t/92_memory_leaks.t
0d512192 143 xt/author/94_includes.t
70f3f307 144 >;
34cc6052
ES
145
146 return
147 map
0d512192 148 { "xt/author/generated/${_}_without_optional_dependencies.t" }
34cc6052
ES
149 @tests_to_be_wrapped;
150}
151
8ddad51b 152my @TARGET_FILES = qw<
8ddad51b 153 t/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.run
d33d2185 154 t/NamingConventions/Capitalization.run
8ddad51b
ES
155 t/Variables/RequireLocalizedPunctuationVars.run
156>;
157
496afbe0 158sub get_PL_files {
8ddad51b 159 my %PL_files = map { ( "$_.PL" => $_ ) } @TARGET_FILES;
6d34b243 160
90806b21 161 $PL_files{'xt/author/generate_without_optional_dependencies_wrappers.PL'} =
0d512192 162 [ test_wrappers_to_generate() ];
496afbe0 163
6d34b243 164 return \%PL_files;
496afbe0
ES
165}
166
70f3f307
ES
167sub dump_unlisted_or_optional_module_versions {
168 print
169 "\nVersions of optional/unlisted/indirect dependencies:\n\n";
170
171 my @unlisted_modules = (
172 qw<
70f3f307
ES
173 >,
174 keys %{ { recommended_module_versions() } },
175 );
176
177 foreach my $module (sort @unlisted_modules) {
178 my $version;
179
910d5187 180 if ($module eq 'Readonly::XS') {
f56c0ad2 181 eval 'use Readonly; use Readonly::XS; $version = $Readonly::XS::VERSION;';
910d5187
ES
182 }
183 else {
184 eval "use $module; \$version = \$${module}::VERSION;";
185 }
70f3f307
ES
186 if ($EVAL_ERROR) {
187 $version = 'not installed';
188 } elsif (not defined $version) {
189 $version = 'undef';
190 }
191
192 print " $module = $version\n";
193 }
194
195 print "\n";
196
197 return;
198}
34cc6052 199
7963ad6d
ES
200sub emit_tar_warning_if_necessary {
201 if ( os_is( qw<Solaris> ) ) {
202 print <<'END_OF_TAR_WARNING';
203NOTE: tar(1) on some Solaris systems cannot deal well with long file
204names.
205
206If you get warnings about missing files below, please ensure that you
207extracted the Perl::Critic tarball using GNU tar.
208
209END_OF_TAR_WARNING
210 }
211}
212
b005b12c
ES
213
214
215
34cc6052
ES
2161;
217
218__END__
219
220=head1 NAME
221
222Perl::Critic::BuildUtilities - Common bits of compiling Perl::Critic.
223
224
225=head1 DESCRIPTION
226
227Various utilities used in assembling Perl::Critic, primary for use by
228*.PL programs that generate code.
229
230
231=head1 IMPORTABLE SUBROUTINES
232
233=over
234
235=item C<recommended_module_versions()>
236
237Returns a hash mapping between recommended (but not required) modules
238for Perl::Critic and the minimum version required of each module,
239
240
241=item C<test_wrappers_to_generate()>
242
243Returns a list of test wrappers to be generated by
90806b21 244F<xt/author/generate_without_optional_dependencies_wrappers.PL>.
34cc6052 245
496afbe0
ES
246
247=item C<get_PL_files()>
248
249Returns a reference to a hash with a mapping from the name of a .PL
250program to an array of the parameters to be passed to it, suited for
251use by L<Module::Build::API/"PL_files"> or
252L<ExtUtils::MakeMaker/"PL_FILES">. May print to C<STDOUT> messages
253about what it is doing.
254
255
70f3f307
ES
256=item C<dump_unlisted_or_optional_module_versions()>
257
258Prints to C<STDOUT> a list of all the unlisted (e.g. things in core
11f53956
ES
259like L<Exporter|Exporter>), optional (e.g.
260L<File::Which|File::Which>), or potentially indirect (e.g.
261L<Readonly::XS|Readonly::XS>) dependencies, plus their versions, if
70f3f307
ES
262they're installed.
263
34cc6052 264
7963ad6d
ES
265=item C<emit_tar_warning_if_necessary()>
266
267On some Solaris systems, C<tar(1)> can't deal with long file names and
268thus files are not correctly extracted from the tarball. So this
269prints a warning if the current system is Solaris.
270
271
34cc6052
ES
272=back
273
274
275=head1 AUTHOR
276
277Elliot Shank C<< <perl@galumph.com> >>
278
279
280=head1 LICENCE AND COPYRIGHT
281
53b8903f 282Copyright (c) 2007-2011, Elliot Shank.
34cc6052
ES
283
284This program is free software; you can redistribute it and/or modify
285it under the same terms as Perl itself. The full text of this license
286can be found in the LICENSE file included with this module.
287
288=cut
289
290##############################################################################
291# Local Variables:
292# mode: cperl
293# cperl-indent-level: 4
294# fill-column: 78
295# indent-tabs-mode: nil
296# c-indentation-style: bsd
297# End:
96fed375 298# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :