← 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/ControlStructures/ProhibitCascadingIfElse.pm
StatementsExecuted 18 statements in 330µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11120µs20µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::BEGIN@10Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@10
1117µs11µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::BEGIN@12Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@12
1117µs28µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::BEGIN@14Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@14
1117µs145µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::BEGIN@16Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@16
1117µs61µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::BEGIN@17Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@17
1117µs18µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::BEGIN@11Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@11
1116µs7µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::default_severityPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::default_severity
1115µs5µsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::supported_parametersPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::supported_parameters
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::_count_elsifsPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::_count_elsifs
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::applies_toPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::applies_to
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::default_themesPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::default_themes
0000s0sPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::::violatesPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::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::ControlStructures::ProhibitCascadingIfElse;
9
10240µs120µ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
use 5.006001;
11220µs230µ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
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@11 # spent 12µs making 1 call to strict::import
12218µs215µ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
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14222µs248µ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
use Readonly;
# spent 28µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@14 # spent 20µs making 1 call to Exporter::import
15
16223µs2283µ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
use Perl::Critic::Utils qw{ :severities };
# spent 145µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@16 # spent 138µs making 1 call to Exporter::import
172191µs2116µ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
use base 'Perl::Critic::Policy';
# spent 61µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse::BEGIN@17 # spent 54µs making 1 call to base::import
18
191500nsour $VERSION = '1.121';
20
21#-----------------------------------------------------------------------------
22
2312µs128µsReadonly::Scalar my $DESC => q{Cascading if-elsif chain};
# spent 28µs making 1 call to Readonly::Scalar
2412µs141µsReadonly::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
sub supported_parameters {
29 return (
30 {
3117µ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
4012µ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
sub default_severity { return $SEVERITY_MEDIUM }
41sub default_themes { return qw( core pbp maintenance complexity ) }
42sub applies_to { return 'PPI::Statement::Compound' }
43
44#-----------------------------------------------------------------------------
45
46sub 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
57sub _count_elsifs {
58 my $elem = shift;
59 return
60 grep { $_->isa('PPI::Token::Word') && $_ eq 'elsif' } $elem->schildren();
61}
62
6313µs1;
64
65__END__