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

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/BuiltinFunctions/ProhibitStringyEval.pm
StatementsExecuted 27166 statements in 52.9ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
134811143.5ms293msPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::violatesPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::violates
14411276µs276µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::applies_toPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::applies_to
11116µs16µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@10Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@10
11110µs10µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@16Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@16
1117µs61µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@19Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@19
1117µs12µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@12Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@12
1117µs28µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@14Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@14
1117µs478µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@18Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@18
1117µs18µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::BEGIN@11Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@11
1116µs8µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::default_severityPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::default_severity
1115µs5µsPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::supported_parametersPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::supported_parameters
0000s0sPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::_string_eval_is_an_includePerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::_string_eval_is_an_include
0000s0sPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::::default_themesPerl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::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##############################################################################
7
8package Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval;
9
10239µs116µs
# spent 16µs within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@11 # spent 11µs making 1 call to strict::import
12222µs216µs
# spent 12µs (7+5) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@12 which was called: # once (7µs+5µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 12µs making 1 call to Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14220µs249µs
# spent 28µs (7+21) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::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::BuiltinFunctions::ProhibitStringyEval::BEGIN@14 # spent 21µs making 1 call to Exporter::import
15
16228µs110µs
# spent 10µs within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@16 which was called: # once (10µs+0s) by Module::Pluggable::Object::_require at line 16
use PPI::Document;
17
18225µs2950µs
# spent 478µs (7+471) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@18 which was called: # once (7µs+471µs) by Module::Pluggable::Object::_require at line 18
use Perl::Critic::Utils qw{ :booleans :severities :classification :ppi $SCOLON };
# spent 478µs making 1 call to Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@18 # spent 471µs making 1 call to Exporter::import
192328µs2114µs
# spent 61µs (7+54) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@19 which was called: # once (7µs+54µs) by Module::Pluggable::Object::_require at line 19
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::BEGIN@19 # spent 54µs making 1 call to base::import
20
211600nsour $VERSION = '1.121';
22
23#-----------------------------------------------------------------------------
24
2512µs12.85msReadonly::Scalar my $DESC => q{Expression form of "eval"};
# spent 2.85ms making 1 call to Readonly::Scalar
2612µs147µsReadonly::Scalar my $EXPL => [ 161 ];
# spent 47µs making 1 call to Readonly::Scalar
27
28#-----------------------------------------------------------------------------
29
30
# spent 5µs within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::supported_parameters which was called: # once (5µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
31 return (
32 {
3318µs name => 'allow_includes',
34 description => q<Allow eval of "use" and "require" strings.>,
35 default_string => '0',
36 behavior => 'boolean',
37 },
38 );
39}
4012µs
# spent 8µs (6+1) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::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_HIGHEST }
41sub default_themes { return qw( core pbp bugs certrule ) }
42144374µs
# spent 276µs within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::applies_to which was called 144 times, avg 2µs/call: # 144 times (276µs+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2µs/call
sub applies_to { return 'PPI::Token::Word' }
43
44#-----------------------------------------------------------------------------
45
46
# spent 293ms (43.5+250) within Perl::Critic::Policy::BuiltinFunctions::ProhibitStringyEval::violates which was called 13481 times, avg 22µs/call: # 13481 times (43.5ms+250ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 22µs/call
sub violates {
47134813.00ms my ( $self, $elem, undef ) = @_;
48
491348148.8ms13481245ms return if $elem ne 'eval';
# spent 245ms making 13481 calls to PPI::Element::__ne, avg 18µs/call
501023µs104.15ms return if not is_function_call($elem);
# spent 4.15ms making 10 calls to Perl::Critic::Utils::is_function_call, avg 415µs/call
51
521021µs10339µs my $argument = first_arg($elem);
# spent 339µs making 10 calls to Perl::Critic::Utils::first_arg, avg 34µs/call
531030µs105µs return if not $argument;
# spent 5µs making 10 calls to PPI::Util::TRUE, avg 510ns/call
541053µs108µs return if $argument->isa('PPI::Structure::Block');
# spent 8µs making 10 calls to UNIVERSAL::isa, avg 800ns/call
55 return if
56 $self->{_allow_includes} and _string_eval_is_an_include($argument);
57
58 return $self->violation( $DESC, $EXPL, $elem );
59}
60
61sub _string_eval_is_an_include {
62 my ($eval_argument) = @_;
63
64 return if not $eval_argument->isa('PPI::Token::Quote');
65
66 my $string = $eval_argument->string();
67 my $document;
68
69 eval { $document = PPI::Document->new(\$string); 1 }
70 or return;
71
72 my @statements = $document->schildren;
73
74 return if @statements > 2;
75 my $include = $statements[0];
76 return if not defined $include; # RT 60179
77 return if not $include->isa('PPI::Statement::Include');
78 return if $include->type() eq 'no';
79
80 if (
81 $eval_argument->isa('PPI::Token::Quote::Single')
82 or $eval_argument->isa('PPI::Token::Quote::Literal')
83 ) {
84 # Don't allow funky inclusion of arbitrary code (note we do allow
85 # interpolated values in interpolating strings because they can't
86 # entirely screw with the syntax).
87 return if $include->find('PPI::Token::Symbol');
88 }
89
90 return $TRUE if @statements == 1;
91
92 my $follow_on = $statements[1];
93 return if not $follow_on->isa('PPI::Statement');
94
95 my @follow_on_components = $follow_on->schildren();
96
97 return if @follow_on_components > 2;
98 return if not $follow_on_components[0]->isa('PPI::Token::Number');
99 return $TRUE if @follow_on_components == 1;
100
101 return $follow_on_components[1]->content() eq $SCOLON;
102}
103
104
10514µs1;
106
107__END__