Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Variables/ProhibitConditionalDeclarations.pm |
Statements | Executed 29676 statements in 57.3ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
12164 | 1 | 1 | 43.8ms | 97.6ms | _is_conditional | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1299 | 1 | 1 | 13.6ms | 277ms | violates | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
144 | 1 | 1 | 283µs | 283µs | applies_to | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 17µs | 17µs | BEGIN@10 | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 12µs | 69µs | BEGIN@16 | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 8µs | 12µs | BEGIN@12 | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 7µs | 466µs | BEGIN@15 | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 7µs | 29µs | BEGIN@13 | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
1 | 1 | 1 | 2µs | 2µs | supported_parameters | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations; | ||||
9 | |||||
10 | 2 | 39µs | 1 | 17µs | # spent 17µs within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@10 which was called:
# once (17µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 17µs making 1 call to Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@10 |
11 | 2 | 24µs | 2 | 30µs | # spent 18µs (7+11) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@11 which was called:
# once (7µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 18µs making 1 call to Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 19µs | 2 | 15µs | # spent 12µs (8+4) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@12 which was called:
# once (8µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 12µs making 1 call to Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 27µs | 2 | 51µs | # spent 29µs (7+22) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@13 which was called:
# once (7µs+22µs) by Module::Pluggable::Object::_require at line 13 # spent 29µs making 1 call to Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@13
# spent 22µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 25µs | 2 | 924µs | # spent 466µs (7+458) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@15 which was called:
# once (7µs+458µs) by Module::Pluggable::Object::_require at line 15 # spent 466µs making 1 call to Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@15
# spent 458µs making 1 call to Exporter::import |
16 | 2 | 212µs | 2 | 126µs | # spent 69µs (12+57) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@16 which was called:
# once (12µs+57µs) by Module::Pluggable::Object::_require at line 16 # spent 69µs making 1 call to Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::BEGIN@16
# spent 57µs making 1 call to base::import |
17 | |||||
18 | 1 | 700ns | our $VERSION = '1.121'; | ||
19 | |||||
20 | #----------------------------------------------------------------------------- | ||||
21 | |||||
22 | 1 | 2µs | 1 | 30µs | Readonly::Scalar my $DESC => q{Variable declared in conditional statement}; # spent 30µs making 1 call to Readonly::Scalar |
23 | 1 | 1µs | 1 | 22µs | Readonly::Scalar my $EXPL => q{Declare variables outside of the condition}; # spent 22µs making 1 call to Readonly::Scalar |
24 | |||||
25 | #----------------------------------------------------------------------------- | ||||
26 | |||||
27 | 1 | 8µs | # spent 2µs within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::supported_parameters which was called:
# once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
28 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
29 | sub default_themes { return qw( core bugs ) } | ||||
30 | 144 | 387µs | # spent 283µs within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::applies_to which was called 144 times, avg 2µs/call:
# 144 times (283µs+0s) by Perl::Critic::_critique at line 165 of Perl/Critic.pm, avg 2µs/call | ||
31 | |||||
32 | #----------------------------------------------------------------------------- | ||||
33 | |||||
34 | # spent 277ms (13.6+263) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::violates which was called 1299 times, avg 213µs/call:
# 1299 times (13.6ms+263ms) by Perl::Critic::_critique at line 183 of Perl/Critic.pm, avg 213µs/call | ||||
35 | 1299 | 397µs | my ( $self, $elem, undef ) = @_; | ||
36 | 1299 | 1.73ms | 1299 | 97.6ms | return if $elem->type() eq 'local'; # spent 97.6ms making 1299 calls to PPI::Statement::Variable::type, avg 75µs/call |
37 | |||||
38 | 1293 | 1.96ms | 1293 | 165ms | if ( $elem->find(\&_is_conditional) ) { # spent 165ms making 1293 calls to PPI::Node::find, avg 128µs/call |
39 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
40 | } | ||||
41 | 1293 | 4.61ms | return; #ok! | ||
42 | } | ||||
43 | |||||
44 | 1 | 2µs | my @conditionals = qw( if while foreach for until unless ); | ||
45 | 1 | 4µs | 1 | 4µs | my %conditionals = hashify( @conditionals ); # spent 4µs making 1 call to Perl::Critic::Utils::hashify |
46 | |||||
47 | # spent 97.6ms (43.8+53.8) within Perl::Critic::Policy::Variables::ProhibitConditionalDeclarations::_is_conditional which was called 12164 times, avg 8µs/call:
# 12164 times (43.8ms+53.8ms) by PPI::Node::find at line 381 of PPI/Node.pm, avg 8µs/call | ||||
48 | 12164 | 2.95ms | my (undef, $elem) = @_; | ||
49 | |||||
50 | 12164 | 44.9ms | 12164 | 53.8ms | return if !$conditionals{$elem}; # spent 39.1ms making 945 calls to PPI::Structure::content, avg 41µs/call
# spent 14.7ms making 11219 calls to PPI::Token::content, avg 1µs/call |
51 | return if ! $elem->isa('PPI::Token::Word'); | ||||
52 | return if is_hash_key($elem); | ||||
53 | return if is_method_call($elem); | ||||
54 | |||||
55 | return 1; | ||||
56 | } | ||||
57 | |||||
58 | 1 | 6µs | 1; | ||
59 | |||||
60 | __END__ |