← 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:11 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ValuesAndExpressions/ProhibitMagicNumbers.pm
StatementsExecuted 42 statements in 1.62ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
33187µs99µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::CORE:regcompPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:regcomp (opcode)
11126µs28µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_determine_allowed_valuesPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_determine_allowed_values
11125µs58µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_parse_allowed_valuesPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_parse_allowed_values
11116µs16µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::BEGIN@10Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@10
11115µs15µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::supported_parametersPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::supported_parameters
11110µs21µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::BEGIN@11Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@11
1117µs420µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::BEGIN@16Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@16
1117µs11µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::BEGIN@12Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@12
1117µs28µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::BEGIN@14Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@14
1117µs61µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::BEGIN@18Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@18
1116µs7µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::default_severityPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::default_severity
3314µs4µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::CORE:qrPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:qr (opcode)
1114µs4µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::CORE:sortPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:sort (opcode)
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_determine_checked_typesPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_determine_checked_types
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_element_is_a_package_statement_version_numberPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_element_is_a_package_statement_version_number
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_element_is_in_a_constant_subroutinePerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_element_is_in_a_constant_subroutine
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_element_is_in_a_plan_statementPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_element_is_in_a_plan_statement
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_element_is_in_an_include_readonly_or_version_statementPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_element_is_in_an_include_readonly_or_version_statement
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_element_is_sole_component_of_a_subscriptPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_element_is_sole_component_of_a_subscript
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::_element_is_to_the_right_of_a_fat_commaPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_element_is_to_the_right_of_a_fat_comma
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::applies_toPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::applies_to
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::default_maximum_violations_per_documentPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::default_maximum_violations_per_document
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::default_themesPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::default_themes
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::initialize_if_enabledPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::initialize_if_enabled
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::::violatesPerl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::violates
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##############################################################################
7
8package Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers;
9
10246µs116µs
# spent 16µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs232µs
# spent 21µs (10+11) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@11 which was called: # once (10µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 21µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@11 # spent 11µs making 1 call to strict::import
12218µs215µs
# spent 11µs (7+4) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@12 which was called: # once (7µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14224µs249µs
# spent 28µs (7+21) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@14 which was called: # once (7µs+21µs) by Module::Pluggable::Object::_require at line 14
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@14 # spent 21µs making 1 call to Exporter::import
15
16225µs2834µs
# spent 420µs (7+413) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@16 which was called: # once (7µs+413µs) by Module::Pluggable::Object::_require at line 16
use Perl::Critic::Utils qw{ :booleans :characters :severities :data_conversion };
# spent 420µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@16 # spent 413µs making 1 call to Exporter::import
17
1821.31ms2114µs
# spent 61µs (7+53) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@18 which was called: # once (7µs+53µs) by Module::Pluggable::Object::_require at line 18
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::BEGIN@18 # spent 53µs making 1 call to base::import
19
201600nsour $VERSION = '1.121';
21
22#----------------------------------------------------------------------------
23
2412µs131µsReadonly::Scalar my $EXPL =>
# spent 31µs making 1 call to Readonly::Scalar
25 q{Unnamed numeric literals make code less maintainable};
261900ns121µsReadonly::Scalar my $USE_READONLY_OR_CONSTANT =>
# spent 21µs making 1 call to Readonly::Scalar
27 ' Use the Readonly or Const::Fast module or the "constant" pragma instead';
2814µs223µsReadonly::Scalar my $TYPE_NOT_ALLOWED_SUFFIX =>
# spent 21µs making 1 call to Readonly::Scalar # spent 2µs making 1 call to Readonly::Scalar::FETCH
29 ") are not allowed.$USE_READONLY_OR_CONSTANT";
30
31127µs547µsReadonly::Scalar my $UNSIGNED_NUMBER =>
# spent 23µs making 1 call to Readonly::Scalar # spent 20µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:regcomp # spent 3µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call # spent 2µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:qr
32 qr{
33 \d+ (?: [$PERIOD] \d+ )? # 1, 1.5, etc.
34 | [$PERIOD] \d+ # .3, .7, etc.
35 }xms;
36122µs442µsReadonly::Scalar my $SIGNED_NUMBER => qr/ [-+]? $UNSIGNED_NUMBER /xms;
# spent 22µs making 1 call to Readonly::Scalar # spent 18µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:regcomp # spent 1µs making 1 call to Readonly::Scalar::FETCH # spent 1µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:qr
37
38153µs1194µsReadonly::Scalar my $RANGE =>
# spent 61µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:regcomp # spent 23µs making 1 call to Readonly::Scalar # spent 9µs making 8 calls to Readonly::Scalar::FETCH, avg 1µs/call # spent 1µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:qr
39 qr{
40 \A
41 ($SIGNED_NUMBER)
42 [$PERIOD] [$PERIOD]
43 ($SIGNED_NUMBER)
44 (?:
45 [$COLON] by [$LEFT_PAREN]
46 ($UNSIGNED_NUMBER)
47 [$RIGHT_PAREN]
48 )?
49 \z
50 }xms;
51
521900ns120µsReadonly::Scalar my $SPECIAL_ARRAY_SUBSCRIPT_EXEMPTION => -1;
# spent 20µs making 1 call to Readonly::Scalar
53
54#----------------------------------------------------------------------------
55
56
# spent 15µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::supported_parameters which was called: # once (15µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
57 return (
58 {
59118µs name => 'allowed_values',
60 description => 'Individual and ranges of values to allow, and/or "all_integers".',
61 default_string => '0 1 2',
62 parser => \&_parse_allowed_values,
63 },
64 {
65 name => 'allowed_types',
66 description => 'Kind of literals to allow.',
67 default_string => 'Float',
68 behavior => 'enumeration',
69 enumeration_values => [ qw{ Binary Exp Float Hex Octal } ],
70 enumeration_allow_multiple_values => 1,
71 },
72 {
73 name => 'allow_to_the_right_of_a_fat_comma',
74 description =>
75 q[Should anything to the right of a "=>" be allowed?],
76 default_string => '1',
77 behavior => 'boolean',
78 },
79 {
80 name => 'constant_creator_subroutines',
81 description => q{Names of subroutines that create constants},
82 behavior => 'string list',
83 list_always_present_values => [
84 qw<
85 Readonly Readonly::Scalar Readonly::Array Readonly::Hash
86 const
87 >,
88 ],
89 },
90 );
91}
92
9312µs
# spent 7µs (6+1) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::default_severity which was called: # once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm
sub default_severity { return $SEVERITY_LOW }
94sub default_themes { return qw( core maintenance certrec ) }
95sub applies_to { return 'PPI::Token::Number' }
96
97sub default_maximum_violations_per_document { return 10; }
98
99#----------------------------------------------------------------------------
100
101sub initialize_if_enabled {
102 my ($self, $config) = @_;
103
104 $self->_determine_checked_types();
105
106 return $TRUE;
107}
108
109
# spent 58µs (25+33) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_parse_allowed_values which was called: # once (25µs+33µs) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm
sub _parse_allowed_values {
1101600ns my ($self, $parameter, $config_string) = @_;
111
11213µs128µs my ( $all_integers_allowed, $allowed_values )
113 = _determine_allowed_values($config_string);
114
1151500ns my $allowed_string = ' is not one of the allowed literal values (';
1161200ns if ($all_integers_allowed) {
117 $allowed_string .= 'all integers';
118
119 if ( %{$allowed_values} ) {
120 $allowed_string .= ', ';
121 }
122 }
123 $allowed_string
124116µs25µs .= ( join ', ', sort { $a <=> $b } keys %{$allowed_values} ) . ').'
# spent 4µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:sort # spent 2µs making 1 call to Readonly::Scalar::FETCH
125 . $USE_READONLY_OR_CONSTANT;
126
1271900ns $self->{_allowed_values} = $allowed_values;
1281700ns $self->{_all_integers_allowed} = $all_integers_allowed;
1291700ns $self->{_allowed_string} = $allowed_string;
130
13114µs return;
132}
133
134
# spent 28µs (26+2) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_determine_allowed_values which was called: # once (26µs+2µs) by Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_parse_allowed_values at line 112
sub _determine_allowed_values {
1351300ns my ($config_string) = @_;
136
1371200ns my @allowed_values;
1381100ns my @potential_allowed_values;
1391500ns my $all_integers_allowed = 0;
140
1411700ns if ( defined $config_string ) {
142 my @allowed_values_strings =
143 grep {$_} split m/\s+/xms, $config_string;
144
145 foreach my $value_string (@allowed_values_strings) {
146 if ($value_string eq 'all_integers') {
147 $all_integers_allowed = 1;
148 } elsif ( $value_string =~ m/ \A $SIGNED_NUMBER \z /xms ) {
149 push @potential_allowed_values, $value_string + 0;
150 } elsif ( $value_string =~ m/$RANGE/xms ) {
151 my ( $minimum, $maximum, $increment ) = ($1, $2, $3);
152 $increment ||= 1;
153
154 $minimum += 0;
155 $maximum += 0;
156 $increment += 0;
157
158 for ( ## no critic (ProhibitCStyleForLoops)
159 my $value = $minimum;
160 $value <= $maximum;
161 $value += $increment
162 ) {
163 push @potential_allowed_values, $value;
164 }
165 } else {
166 die q{Invalid value for allowed_values: }, $value_string,
167 q{. Must be a number, a number range, or},
168 qq{ "all_integers".\n};
169 }
170 }
171
172 if ($all_integers_allowed) {
173 @allowed_values = grep { $_ != int $_ } @potential_allowed_values;
174 } else {
175 @allowed_values = @potential_allowed_values;
176 }
177 } else {
1781500ns @allowed_values = (2);
179 }
180
1811800ns if ( not $all_integers_allowed ) {
182 push @allowed_values, 0, 1;
183 }
18414µs12µs my %allowed_values = hashify(@allowed_values);
# spent 2µs making 1 call to Perl::Critic::Utils::hashify
185
18615µs return ( $all_integers_allowed, \%allowed_values );
187}
188
189sub _determine_checked_types {
190 my ($self) = @_;
191
192 my %checked_types = (
193 'PPI::Token::Number::Binary' => 'Binary literals (',
194 'PPI::Token::Number::Float' => 'Floating-point literals (',
195 'PPI::Token::Number::Exp' => 'Exponential literals (',
196 'PPI::Token::Number::Hex' => 'Hexadecimal literals (',
197 'PPI::Token::Number::Octal' => 'Octal literals (',
198 'PPI::Token::Number::Version' => 'Version literals (',
199 );
200
201 # This will be set by the enumeration behavior specified in
202 # supported_parameters() above.
203 my $allowed_types = $self->{_allowed_types};
204
205 foreach my $allowed_type ( keys %{$allowed_types} ) {
206 delete $checked_types{"PPI::Token::Number::$allowed_type"};
207
208 if ( $allowed_type eq 'Exp' ) {
209
210 # because an Exp isa(Float).
211 delete $checked_types{'PPI::Token::Number::Float'};
212 }
213 }
214
215 $self->{_checked_types} = \%checked_types;
216
217 return;
218}
219
220
221sub violates {
222 my ( $self, $elem, undef ) = @_;
223
224 if ( $self->{_allow_to_the_right_of_a_fat_comma} ) {
225 return if _element_is_to_the_right_of_a_fat_comma($elem);
226 }
227
228 return if _element_is_in_an_include_readonly_or_version_statement(
229 $self, $elem,
230 );
231 return if _element_is_in_a_plan_statement($elem);
232 return if _element_is_in_a_constant_subroutine($elem);
233 return if _element_is_a_package_statement_version_number($elem);
234
235 my $literal = $elem->literal();
236 if (
237 defined $literal
238 and not (
239 $self->{_all_integers_allowed}
240 and int $literal == $literal
241 )
242 and not defined $self->{_allowed_values}{$literal}
243 and not (
244 _element_is_sole_component_of_a_subscript($elem)
245 and $literal == $SPECIAL_ARRAY_SUBSCRIPT_EXEMPTION
246 )
247 ) {
248 return
249 $self->violation(
250 $elem->content() . $self->{_allowed_string},
251 $EXPL,
252 $elem,
253 );
254 }
255
256
257 my ( $number_type, $type_string );
258
259 while (
260 ( $number_type, $type_string ) = ( each %{ $self->{_checked_types} } )
261 ) {
262 if ( $elem->isa($number_type) ) {
263 return
264 $self->violation(
265 $type_string . $elem->content() . $TYPE_NOT_ALLOWED_SUFFIX,
266 $EXPL,
267 $elem,
268 );
269 }
270 }
271
272 return;
273}
274
275sub _element_is_to_the_right_of_a_fat_comma {
276 my ($elem) = @_;
277
278 my $previous = $elem->sprevious_sibling() or return;
279
280 $previous->isa('PPI::Token::Operator') or return;
281
282 return $previous->content() eq q[=>];
283}
284
285sub _element_is_sole_component_of_a_subscript {
286 my ($elem) = @_;
287
288 my $parent = $elem->parent();
289 if ( $parent and $parent->isa('PPI::Statement::Expression') ) {
290 if ( $parent->schildren() > 1 ) {
291 return 0;
292 }
293
294 my $grandparent = $parent->parent();
295 if (
296 $grandparent
297 and $grandparent->isa('PPI::Structure::Subscript')
298 ) {
299 return 1;
300 }
301 }
302
303 return 0;
304}
305
306sub _element_is_in_an_include_readonly_or_version_statement {
307 my ($self, $elem) = @_;
308
309 my $parent = $elem->parent();
310 while ($parent) {
311 if ( $parent->isa('PPI::Statement') ) {
312 return 1 if $parent->isa('PPI::Statement::Include');
313
314 if ( $parent->isa('PPI::Statement::Variable') ) {
315 if ( $parent->type() eq 'our' ) {
316 my @variables = $parent->variables();
317 if (
318 scalar @variables == 1
319 and $variables[0] eq '$VERSION' ## no critic (RequireInterpolationOfMetachars)
320 ) {
321 return 1;
322 }
323 }
324
325 return 0;
326 }
327
328 my $first_token = $parent->first_token();
329 if ( $first_token->isa('PPI::Token::Word') ) {
330 if ( $self->{_constant_creator_subroutines}{
331 $first_token->content() } ) {
332 return 1;
333 }
334 } elsif ($parent->isa('PPI::Structure::Block')) {
335 return 0;
336 }
337 }
338
339 $parent = $parent->parent();
340 }
341
342 return 0;
343}
344
345# Allow "plan tests => 39;".
346
3471800ns119µsReadonly::Scalar my $PLAN_STATEMENT_MINIMUM_TOKENS => 4;
# spent 19µs making 1 call to Readonly::Scalar
348
349sub _element_is_in_a_plan_statement {
350 my ($elem) = @_;
351
352 my $parent = $elem->parent();
353 return 0 if not $parent;
354
355 return 0 if not $parent->isa('PPI::Statement');
356
357 my @children = $parent->schildren();
358 return 0 if @children < $PLAN_STATEMENT_MINIMUM_TOKENS;
359
360 return 0 if not $children[0]->isa('PPI::Token::Word');
361 return 0 if $children[0]->content() ne 'plan';
362
363 return 0 if not $children[1]->isa('PPI::Token::Word');
364 return 0 if $children[1]->content() ne 'tests';
365
366 return 0 if not $children[2]->isa('PPI::Token::Operator');
367 return 0 if $children[2]->content() ne '=>';
368
369 return 1;
370}
371
372sub _element_is_in_a_constant_subroutine {
373 my ($elem) = @_;
374
375 my $parent = $elem->parent();
376 return 0 if not $parent;
377
378 return 0 if not $parent->isa('PPI::Statement');
379
380 my $following = $elem->snext_sibling();
381 if ($following) {
382 return 0 if not $following->isa('PPI::Token::Structure');
383 return 0 if $following->content() ne $SCOLON;
384 return 0 if $following->snext_sibling();
385 }
386
387 my $preceding = $elem->sprevious_sibling();
388 if ($preceding) {
389 return 0 if not $preceding->isa('PPI::Token::Word');
390 return 0 if $preceding->content() ne 'return';
391 return 0 if $preceding->sprevious_sibling();
392 }
393
394 return 0 if $parent->snext_sibling();
395 return 0 if $parent->sprevious_sibling();
396
397 my $grandparent = $parent->parent();
398 return 0 if not $grandparent;
399
400 return 0 if not $grandparent->isa('PPI::Structure::Block');
401
402 my $greatgrandparent = $grandparent->parent();
403 return 0 if not $greatgrandparent;
404 return 0 if not $greatgrandparent->isa('PPI::Statement::Sub');
405
406 return 1;
407}
408
409sub _element_is_a_package_statement_version_number {
410 my ($elem) = @_;
411
412 my $parent = $elem->statement()
413 or return 0;
414
415 $parent->isa( 'PPI::Statement::Package' )
416 or return 0;
417
418 my $version = $parent->schild( 2 )
419 or return 0;
420
421 return $version == $elem;
422}
423
42419µs1;
425
426__END__
 
# spent 4µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:qr which was called 3 times, avg 1µs/call: # once (2µs+0s) by Module::Pluggable::Object::_require at line 31 # once (1µs+0s) by Module::Pluggable::Object::_require at line 38 # once (1µs+0s) by Module::Pluggable::Object::_require at line 36
sub Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:qr; # opcode
# spent 99µs (87+13) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:regcomp which was called 3 times, avg 33µs/call: # once (53µs+9µs) by Module::Pluggable::Object::_require at line 38 # once (18µs+3µs) by Module::Pluggable::Object::_require at line 31 # once (16µs+1µs) by Module::Pluggable::Object::_require at line 36
sub Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:regcomp; # opcode
# spent 4µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:sort which was called: # once (4µs+0s) by Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::_parse_allowed_values at line 124
sub Perl::Critic::Policy::ValuesAndExpressions::ProhibitMagicNumbers::CORE:sort; # opcode