← 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/ProhibitConditionalUseStatements.pm
StatementsExecuted 19 statements in 506µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::BEGIN@10Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@10
11110µs14µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::BEGIN@12Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@12
1117µs61µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::BEGIN@16Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@16
1117µs28µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::BEGIN@13Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@13
1117µs9µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::default_severityPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::default_severity
1117µs191µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::BEGIN@15Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@15
1117µs18µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::BEGIN@11Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@11
1112µs2µsPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::supported_parametersPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::supported_parameters
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::_is_compound_statementPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::_is_compound_statement
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::_is_evalPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::_is_eval
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::_is_in_conditional_logicPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::_is_in_conditional_logic
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::_is_in_do_conditional_blockPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::_is_in_do_conditional_block
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::applies_toPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::applies_to
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::default_themesPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::default_themes
0000s0sPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::::violatesPerl::Critic::Policy::Modules::ProhibitConditionalUseStatements::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::Modules::ProhibitConditionalUseStatements;
9
10239µs116µs
# spent 16µs within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11223µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::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::Modules::ProhibitConditionalUseStatements::BEGIN@11 # spent 11µs making 1 call to strict::import
12219µs218µs
# spent 14µs (10+4) within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@12 which was called: # once (10µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 14µs making 1 call to Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@12 # spent 4µs making 1 call to warnings::import
13222µs248µs
# spent 28µs (7+21) within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@13 which was called: # once (7µs+21µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@13 # spent 21µs making 1 call to Exporter::import
14
15224µs2376µs
# spent 191µs (7+184) within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@15 which was called: # once (7µs+184µs) by Module::Pluggable::Object::_require at line 15
use Perl::Critic::Utils qw{ :booleans :severities };
# spent 191µs making 1 call to Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@15 # spent 184µs making 1 call to Exporter::import
162362µs2114µs
# spent 61µs (7+53) within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@16 which was called: # once (7µs+53µs) by Module::Pluggable::Object::_require at line 16
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::BEGIN@16 # spent 53µs making 1 call to base::import
17
181600nsour $VERSION = '1.121';
19
20#-----------------------------------------------------------------------------
21
2212µs128µsReadonly::Scalar my $DESC => q{Conditional "use" statement};
# spent 28µs making 1 call to Readonly::Scalar
2311µs121µsReadonly::Scalar my $EXPL => q{Use "require" to conditionally include a module.};
# spent 21µs making 1 call to Readonly::Scalar
24
25# operators
26
2713µs125µsReadonly::Hash my %OPS => map { $_ => 1 } qw( || && or and );
# spent 25µs making 1 call to Readonly::Hash
28
29#-----------------------------------------------------------------------------
30
3115µs
# spent 2µs within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::supported_parameters which was called: # once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return () }
3212µs
# spent 9µs (7+2) within Perl::Critic::Policy::Modules::ProhibitConditionalUseStatements::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_MEDIUM }
33sub default_themes { return qw( core bugs ) }
34sub applies_to { return 'PPI::Statement::Include' }
35
36#-----------------------------------------------------------------------------
37
38sub violates {
39 my ( $self, $elem, $doc ) = @_;
40 return $self->violation( $DESC, $EXPL, $elem ) if $elem->type() eq 'use'
41 && !$elem->pragma()
42 && $elem->module()
43 && $self->_is_in_conditional_logic($elem);
44 return;
45}
46
47#-----------------------------------------------------------------------------
48
49# is this a non-string eval statement
50
51sub _is_eval {
52 my ( $self, $elem ) = @_;
53 $elem->isa('PPI::Statement') or return;
54 my $first_elem = $elem->first_element();
55 return $TRUE if $first_elem->isa('PPI::Token::Word')
56 && $first_elem eq 'eval';
57 return;
58}
59
60#-----------------------------------------------------------------------------
61
62# is this in a conditional do block
63
64sub _is_in_do_conditional_block {
65 my ( $self, $elem ) = @_;
66 return if !$elem->isa('PPI::Structure::Block');
67 my $prev_sibling = $elem->sprevious_sibling() or return;
68 if ($prev_sibling->isa('PPI::Token::Word') && $prev_sibling eq 'do') {
69 my $next_sibling = $elem->snext_sibling();
70 return $TRUE if $next_sibling
71 && $next_sibling->isa('PPI::Token::Word');
72 $prev_sibling = $prev_sibling->sprevious_sibling() or return;
73 return $TRUE if $prev_sibling->isa('PPI::Token::Operator')
74 && $OPS{$prev_sibling->content()};
75 }
76 return;
77}
78
79#-----------------------------------------------------------------------------
80
81# is this a compound statement
82
83sub _is_compound_statement {
84 my ( $self, $elem ) = @_;
85 return if !$elem->isa('PPI::Statement::Compound');
86 return $TRUE if $elem->type() ne 'continue'; # exclude bare blocks
87 return;
88}
89
90#-----------------------------------------------------------------------------
91
92# is this contained in conditional logic
93
94sub _is_in_conditional_logic {
95 my ( $self, $elem ) = @_;
96 while ($elem = $elem->parent()) {
97 last if $elem->isa('PPI::Document');
98 return $TRUE if $self->_is_compound_statement($elem)
99 || $self->_is_eval($elem)
100 || $self->_is_in_do_conditional_block($elem);
101 }
102 return;
103}
104
10515µs1;
106
107__END__