Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ControlStructures/ProhibitCascadingIfElse.pm |
Statements | Executed 18 statements in 330µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 20µs | 20µs | BEGIN@10 | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 7µs | 28µs | BEGIN@14 | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 7µs | 145µs | BEGIN@16 | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 7µs | 61µs | BEGIN@17 | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
1 | 1 | 1 | 5µs | 5µs | supported_parameters | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
0 | 0 | 0 | 0s | 0s | _count_elsifs | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::
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::ControlStructures::ProhibitCascadingIfElse; | ||||
9 | |||||
10 | 2 | 40µs | 1 | 20µs | # spent 20µs within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@10 which was called:
# once (20µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 20µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@10 |
11 | 2 | 20µs | 2 | 30µs | # spent 18µs (7+11) within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::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::ControlStructures::ProhibitCascadingIfElse::BEGIN@11
# spent 12µs making 1 call to strict::import |
12 | 2 | 18µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@12 which was called:
# once (7µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 11µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | |||||
14 | 2 | 22µs | 2 | 48µs | # spent 28µs (7+20) within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@14 which was called:
# once (7µs+20µs) by Module::Pluggable::Object::_require at line 14 # spent 28µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@14
# spent 20µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 23µs | 2 | 283µs | # spent 145µs (7+138) within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@16 which was called:
# once (7µs+138µs) by Module::Pluggable::Object::_require at line 16 # spent 145µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@16
# spent 138µs making 1 call to Exporter::import |
17 | 2 | 191µs | 2 | 116µs | # spent 61µs (7+54) within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@17 which was called:
# once (7µs+54µs) by Module::Pluggable::Object::_require at line 17 # spent 61µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@17
# spent 54µs making 1 call to base::import |
18 | |||||
19 | 1 | 500ns | our $VERSION = '1.121'; | ||
20 | |||||
21 | #----------------------------------------------------------------------------- | ||||
22 | |||||
23 | 1 | 2µs | 1 | 28µs | Readonly::Scalar my $DESC => q{Cascading if-elsif chain}; # spent 28µs making 1 call to Readonly::Scalar |
24 | 1 | 2µs | 1 | 41µs | Readonly::Scalar my $EXPL => [ 117, 118 ]; # spent 41µs making 1 call to Readonly::Scalar |
25 | |||||
26 | #----------------------------------------------------------------------------- | ||||
27 | |||||
28 | # spent 5µs within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::supported_parameters which was called:
# once (5µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
29 | return ( | ||||
30 | { | ||||
31 | 1 | 7µs | name => 'max_elsif', | ||
32 | description => 'The maximum number of alternatives that will be allowed.', | ||||
33 | default_string => '2', | ||||
34 | behavior => 'integer', | ||||
35 | integer_minimum => 1, | ||||
36 | }, | ||||
37 | ); | ||||
38 | } | ||||
39 | |||||
40 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
41 | sub default_themes { return qw( core pbp maintenance complexity ) } | ||||
42 | sub applies_to { return 'PPI::Statement::Compound' } | ||||
43 | |||||
44 | #----------------------------------------------------------------------------- | ||||
45 | |||||
46 | sub violates { | ||||
47 | my ( $self, $elem, undef ) = @_; | ||||
48 | |||||
49 | return if ($elem->type() ne 'if'); | ||||
50 | |||||
51 | if ( _count_elsifs($elem) > $self->{_max_elsif} ) { | ||||
52 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
53 | } | ||||
54 | return; #ok! | ||||
55 | } | ||||
56 | |||||
57 | sub _count_elsifs { | ||||
58 | my $elem = shift; | ||||
59 | return | ||||
60 | grep { $_->isa('PPI::Token::Word') && $_ eq 'elsif' } $elem->schildren(); | ||||
61 | } | ||||
62 | |||||
63 | 1 | 3µs | 1; | ||
64 | |||||
65 | __END__ |