← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:12 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Modules/ProhibitEvilModules.pm
StatementsExecuted 9042 statements in 7.11ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
982116.11ms37.1msPerl::Critic::Policy::Modules::ProhibitEvilModules::::violatesPerl::Critic::Policy::Modules::ProhibitEvilModules::violates
14411305┬Ás305┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::applies_toPerl::Critic::Policy::Modules::ProhibitEvilModules::applies_to
741143┬Ás155┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::CORE:regcompPerl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp (opcode)
11164┬Ás186┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::_parse_modulesPerl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules
41129┬Ás29┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::_handle_module_specificationPerl::Critic::Policy::Modules::ProhibitEvilModules::_handle_module_specification
11122┬Ás26┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::supported_parametersPerl::Critic::Policy::Modules::ProhibitEvilModules::supported_parameters
52118┬Ás18┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::CORE:substPerl::Critic::Policy::Modules::ProhibitEvilModules::CORE:subst (opcode)
11116┬Ás16┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@9Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@9
11110┬Ás30┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@17Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@17
1118┬Ás410┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@13Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@13
1118┬Ás74┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@22Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@22
1118┬Ás27┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@14Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@14
1117┬Ás11┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@11Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@11
1117┬Ás9┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::default_severityPerl::Critic::Policy::Modules::ProhibitEvilModules::default_severity
1117┬Ás471┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@18Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@18
1117┬Ás18┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::BEGIN@10Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@10
5516┬Ás6┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::CORE:qrPerl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr (opcode)
1114┬Ás4┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::initialize_if_enabledPerl::Critic::Policy::Modules::ProhibitEvilModules::initialize_if_enabled
1112┬Ás2┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::CORE:matchPerl::Critic::Policy::Modules::ProhibitEvilModules::CORE:match (opcode)
1112┬Ás2┬ÁsPerl::Critic::Policy::Modules::ProhibitEvilModules::::_parse_modules_filePerl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules_file
0000s0sPerl::Critic::Policy::Modules::ProhibitEvilModules::::_handle_module_specification_on_linePerl::Critic::Policy::Modules::ProhibitEvilModules::_handle_module_specification_on_line
0000s0sPerl::Critic::Policy::Modules::ProhibitEvilModules::::default_themesPerl::Critic::Policy::Modules::ProhibitEvilModules::default_themes
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7package Perl::Critic::Policy::Modules::ProhibitEvilModules;
8
9240┬Ás116┬Ás
# spent 16┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@9 which was called: # once (16┬Ás+0s) by Module::Pluggable::Object::_require at line 9
use 5.006001;
10222┬Ás229┬Ás
# spent 18┬Ás (7+11) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@10 which was called: # once (7┬Ás+11┬Ás) by Module::Pluggable::Object::_require at line 10
use strict;
# spent 18┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@10 # spent 11┬Ás making 1 call to strict::import
11221┬Ás214┬Ás
# spent 11┬Ás (7+4) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@11 which was called: # once (7┬Ás+4┬Ás) by Module::Pluggable::Object::_require at line 11
use warnings;
# spent 11┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@11 # spent 4┬Ás making 1 call to warnings::import
12
13224┬Ás2812┬Ás
# spent 410┬Ás (8+402) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@13 which was called: # once (8┬Ás+402┬Ás) by Module::Pluggable::Object::_require at line 13
use English qw(-no_match_vars);
# spent 410┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@13 # spent 402┬Ás making 1 call to English::import
14223┬Ás246┬Ás
# spent 27┬Ás (8+19) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@14 which was called: # once (8┬Ás+19┬Ás) by Module::Pluggable::Object::_require at line 14
use Readonly;
# spent 27┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@14 # spent 19┬Ás making 1 call to Exporter::import
15
16use Perl::Critic::Exception::Configuration::Option::Policy::ParameterValue
17225┬Ás250┬Ás
# spent 30┬Ás (10+20) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@17 which was called: # once (10┬Ás+20┬Ás) by Module::Pluggable::Object::_require at line 17
qw{ throw_policy_value };
# spent 30┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@17 # spent 20┬Ás making 1 call to Exporter::import
181200ns
# spent 471┬Ás (7+464) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@18 which was called: # once (7┬Ás+464┬Ás) by Module::Pluggable::Object::_require at line 20
use Perl::Critic::Utils qw{
19 :booleans :characters :severities :data_conversion
20124┬Ás2936┬Ás};
# spent 471┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@18 # spent 464┬Ás making 1 call to Exporter::import
21
222910┬Ás2141┬Ás
# spent 74┬Ás (8+66) within Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@22 which was called: # once (8┬Ás+66┬Ás) by Module::Pluggable::Object::_require at line 22
use base 'Perl::Critic::Policy';
# spent 74┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::BEGIN@22 # spent 66┬Ás making 1 call to base::import
23
241700nsour $VERSION = '1.121';
25
26#-----------------------------------------------------------------------------
27
2812┬Ás133┬ÁsReadonly::Scalar my $EXPL => q{Find an alternative module};
# spent 33┬Ás making 1 call to Readonly::Scalar
29
3017┬Ás224┬ÁsReadonly::Scalar my $MODULE_NAME_REGEX =>
# spent 23┬Ás making 1 call to Readonly::Scalar # spent 1┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr
31 qr<
32 \b
33 [[:alpha:]_]
34 (?:
35 (?: \w | :: )*
36 \w
37 )?
38 \b
39 >xms;
4015┬Ás222┬ÁsReadonly::Scalar my $REGULAR_EXPRESSION_REGEX => qr< [/] ( [^/]+ ) [/] >xms;
# spent 21┬Ás making 1 call to Readonly::Scalar # spent 1┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr
4114┬Ás221┬ÁsReadonly::Scalar my $DESCRIPTION_REGEX => qr< [{] ( [^}]+ ) [}] >xms;
# spent 20┬Ás making 1 call to Readonly::Scalar # spent 1┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr
42
43# It's kind of unfortunate that I had to put capturing parentheses in the
44# component regexes above, because they're not visible here and so make
45# figuring out the positions of captures hard. Too bad we can't make the
46# minimum perl version 5.10. :]
47148┬Ás672┬ÁsReadonly::Scalar my $MODULES_REGEX =>
# spent 44┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp # spent 23┬Ás making 1 call to Readonly::Scalar # spent 4┬Ás making 3 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call # spent 1┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr
48 qr<
49 \A
50 \s*
51 (?:
52 ( $MODULE_NAME_REGEX )
53 | $REGULAR_EXPRESSION_REGEX
54 )
55 (?: \s* $DESCRIPTION_REGEX )?
56 \s*
57 >xms;
58
59141┬Ás565┬ÁsReadonly::Scalar my $MODULES_FILE_LINE_REGEX =>
# spent 38┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp # spent 23┬Ás making 1 call to Readonly::Scalar # spent 2┬Ás making 2 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call # spent 1┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr
60 qr<
61 \A
62 \s*
63 (?:
64 ( $MODULE_NAME_REGEX )
65 | $REGULAR_EXPRESSION_REGEX
66 )
67 \s*
68 ( \S (?: .* \S )? )?
69 \s*
70 \z
71 >xms;
72
73Readonly::Scalar my $DEFAULT_MODULES =>
74 join
75 $SPACE,
7618┬Ás223┬Ás map { "$_ {Found use of $_. This module is deprecated by the Perl 5 Porters.}" }
# spent 21┬Ás making 1 call to Readonly::Scalar # spent 2┬Ás making 1 call to Readonly::Scalar::FETCH
77 qw< Class::ISA Pod::Plainer Shell Switch >;
78
79# Indexes in the arrays of regexes for the "modules" option.
8011┬Ás120┬ÁsReadonly::Scalar my $INDEX_REGEX => 0;
# spent 20┬Ás making 1 call to Readonly::Scalar
811900ns120┬ÁsReadonly::Scalar my $INDEX_DESCRIPTION => 1;
# spent 20┬Ás making 1 call to Readonly::Scalar
82
83#-----------------------------------------------------------------------------
84
85
# spent 26┬Ás (22+5) within Perl::Critic::Policy::Modules::ProhibitEvilModules::supported_parameters which was called: # once (22┬Ás+5┬Ás) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
86 return (
87 {
88117┬Ás45┬Ás name => 'modules',
# spent 5┬Ás making 4 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call
89 description => 'The names of or patterns for modules to forbid.',
90 default_string => $DEFAULT_MODULES,
91 parser => \&_parse_modules,
92 },
93 {
94 name => 'modules_file',
95 description => 'A file containing names of or patterns for modules to forbid.',
96 default_string => $EMPTY,
97 parser => \&_parse_modules_file,
98 },
99 );
100}
101
10212┬Ás
# spent 9┬Ás (7+2) within Perl::Critic::Policy::Modules::ProhibitEvilModules::default_severity which was called: # once (7┬Ás+2┬Ás) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_HIGHEST }
103sub default_themes { return qw( core bugs certrule ) }
104144379┬Ás
# spent 305┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::applies_to which was called 144 times, avg 2┬Ás/call: # 144 times (305┬Ás+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2┬Ás/call
sub applies_to { return 'PPI::Statement::Include' }
105
106#-----------------------------------------------------------------------------
107
108
# spent 186┬Ás (64+122) within Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules which was called: # once (64┬Ás+122┬Ás) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm
sub _parse_modules {
1091400ns my ($self, $parameter, $config_string) = @_;
110
11112┬Ás11┬Ás my $module_specifications =
# spent 1┬Ás making 1 call to Perl::Critic::PolicyParameter::get_default_string
112 defined $config_string
113 ? $config_string
114 : $parameter->get_default_string();
115
1161300ns return if not $module_specifications;
11718┬Ás12┬Ás return if $module_specifications =~ m< \A \s* \z >xms;
118
119164┬Ás358┬Ás while ( $module_specifications =~ s< $MODULES_REGEX ><>xms ) {
# spent 50┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp # spent 6┬Ás making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:subst # spent 1┬Ás making 1 call to Readonly::Scalar::FETCH
12046┬Ás my ($module, $regex_string, $description) = ($1, $2, $3);
121
122448┬Ás1668┬Ás $self->_handle_module_specification(
# spent 29┬Ás making 4 calls to Perl::Critic::Policy::Modules::ProhibitEvilModules::_handle_module_specification, avg 7┬Ás/call # spent 23┬Ás making 4 calls to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp, avg 6┬Ás/call # spent 12┬Ás making 4 calls to Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:subst, avg 3┬Ás/call # spent 5┬Ás making 4 calls to Readonly::Scalar::FETCH, avg 1┬Ás/call
123 module => $module,
124 regex_string => $regex_string,
125 description => $description,
126 option_name => 'modules',
127 option_value => $config_string,
128 );
129 }
130
1311200ns if ($module_specifications) {
132 throw_policy_value
133 policy => $self->get_short_name(),
134 option_name => 'modules',
135 option_value => $config_string,
136 message_suffix =>
137 qq{contains unparseable data: "$module_specifications"};
138 }
139
14014┬Ás return;
141}
142
143
# spent 2┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules_file which was called: # once (2┬Ás+0s) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm
sub _parse_modules_file {
1441400ns my ($self, $parameter, $config_string) = @_;
145
14614┬Ás return if not $config_string;
147 return if $config_string =~ m< \A \s* \z >xms;
148
149 open my $handle, '<', $config_string
150 or throw_policy_value
151 policy => $self->get_short_name(),
152 option_name => 'modules_file',
153 option_value => $config_string,
154 message_suffix =>
155 qq<refers to a file that could not be opened: $OS_ERROR>;
156 while ( my $line = <$handle> ) {
157 $self->_handle_module_specification_on_line($line, $config_string);
158 }
159 close $handle or warn qq<Could not close "$config_string": $OS_ERROR\n>;
160
161 return;
162}
163
164sub _handle_module_specification_on_line {
165 my ($self, $line, $config_string) = @_;
166
167 $line =~ s< [#] .* \z ><>xms;
168 $line =~ s< \s+ \z ><>xms;
169 $line =~ s< \A \s+ ><>xms;
170
171 return if not $line;
172
173 if ( $line =~ s< $MODULES_FILE_LINE_REGEX ><>xms ) {
174 my ($module, $regex_string, $description) = ($1, $2, $3);
175
176 $self->_handle_module_specification(
177 module => $module,
178 regex_string => $regex_string,
179 description => $description,
180 option_name => 'modules_file',
181 option_value => $config_string,
182 );
183 }
184 else {
185 throw_policy_value
186 policy => $self->get_short_name(),
187 option_name => 'modules_file',
188 option_value => $config_string,
189 message_suffix =>
190 qq{contains unparseable data: "$line"};
191 }
192
193 return;
194}
195
196
# spent 29┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::_handle_module_specification which was called 4 times, avg 7┬Ás/call: # 4 times (29┬Ás+0s) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 122, avg 7┬Ás/call
sub _handle_module_specification {
19749┬Ás my ($self, %arguments) = @_;
198
19942┬Ás my $description = $arguments{description} || $EMPTY;
200
20142┬Ás if ( my $regex_string = $arguments{regex_string} ) {
202 # These are module name patterns (e.g. /Acme/)
203 my $actual_regex;
204
205 eval { $actual_regex = qr/$regex_string/; 1 } ## no critic (ExtendedFormatting, LineBoundaryMatching, DotMatchAnything)
206 or throw_policy_value
207 policy => $self->get_short_name(),
208 option_name => $arguments{option_name},
209 option_value => $arguments{option_value},
210 message_suffix =>
211 qq{contains an invalid regular expression: "$regex_string"};
212
213 # Can't use a hash due to stringification, so this is an AoA.
214 $self->{_evil_modules_regexes} ||= [];
215
216 push
217 @{ $self->{_evil_modules_regexes} },
218 [ $actual_regex, $description ];
219 }
220 else {
221 # These are literal module names (e.g. Acme::Foo)
22242┬Ás $self->{_evil_modules} ||= {};
22344┬Ás $self->{_evil_modules}{ $arguments{module} } = $description;
224 }
225
226413┬Ás return;
227}
228
229#-----------------------------------------------------------------------------
230
231
# spent 4┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::initialize_if_enabled which was called: # once (4┬Ás+0s) by Perl::Critic::Config::_add_policy_if_enabled at line 202 of Perl/Critic/Config.pm
sub initialize_if_enabled {
2321400ns my ($self, $config) = @_;
233
234 # Disable if no modules are specified; there's no point in running if
235 # there aren't any.
236 return
23716┬Ás exists $self->{_evil_modules}
238 || exists $self->{_evil_modules_regexes};
239}
240
241#-----------------------------------------------------------------------------
242
243
# spent 37.1ms (6.11+31.0) within Perl::Critic::Policy::Modules::ProhibitEvilModules::violates which was called 982 times, avg 38┬Ás/call: # 982 times (6.11ms+31.0ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 38┬Ás/call
sub violates {
244982295┬Ás my ( $self, $elem, undef ) = @_;
245
2469821.39ms98231.0ms my $module = $elem->module();
# spent 31.0ms making 982 calls to PPI::Statement::Include::module, avg 32┬Ás/call
247982393┬Ás return if not $module;
248
249840324┬Ás my $evil_modules = $self->{_evil_modules};
250840185┬Ás my $evil_modules_regexes = $self->{_evil_modules_regexes};
25184025┬Ás my $description;
252
253840342┬Ás if ( exists $evil_modules->{$module} ) {
254 $description = $evil_modules->{ $module };
255 }
256 else {
257 REGEX:
258840564┬Ás foreach my $regex ( @{$evil_modules_regexes} ) {
259 if ( $module =~ $regex->[$INDEX_REGEX] ) {
260 $description = $regex->[$INDEX_DESCRIPTION];
261 last REGEX;
262 }
263 }
264 }
265
266840109┬Ás if (defined $description) {
267 $description ||= qq<Prohibited module "$module" used>;
268
269 return $self->violation( $description, $EXPL, $elem );
270 }
271
2728401.69ms return; # ok!
273}
274
275115┬Ás1;
276
277__END__
 
# spent 2┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:match which was called: # once (2┬Ás+0s) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 117
sub Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:match; # opcode
# spent 6┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr which was called 5 times, avg 1┬Ás/call: # once (1┬Ás+0s) by Module::Pluggable::Object::_require at line 47 # once (1┬Ás+0s) by Module::Pluggable::Object::_require at line 30 # once (1┬Ás+0s) by Module::Pluggable::Object::_require at line 59 # once (1┬Ás+0s) by Module::Pluggable::Object::_require at line 40 # once (1┬Ás+0s) by Module::Pluggable::Object::_require at line 41
sub Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:qr; # opcode
# spent 155┬Ás (143+12) within Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp which was called 7 times, avg 22┬Ás/call: # 4 times (18┬Ás+5┬Ás) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 122, avg 6┬Ás/call # once (49┬Ás+1┬Ás) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 119 # once (41┬Ás+4┬Ás) by Module::Pluggable::Object::_require at line 47 # once (36┬Ás+2┬Ás) by Module::Pluggable::Object::_require at line 59
sub Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:regcomp; # opcode
# spent 18┬Ás within Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:subst which was called 5 times, avg 4┬Ás/call: # 4 times (12┬Ás+0s) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 122, avg 3┬Ás/call # once (6┬Ás+0s) by Perl::Critic::Policy::Modules::ProhibitEvilModules::_parse_modules at line 119
sub Perl::Critic::Policy::Modules::ProhibitEvilModules::CORE:subst; # opcode