| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Subroutines/ProhibitExcessComplexity.pm |
| Statements | Executed 19 statements in 406µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 546µs | 1.10ms | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@16 |
| 1 | 1 | 1 | 16µs | 16µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@10 |
| 1 | 1 | 1 | 7µs | 11µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 434µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@15 |
| 1 | 1 | 1 | 7µs | 61µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@18 |
| 1 | 1 | 1 | 7µs | 27µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@13 |
| 1 | 1 | 1 | 7µs | 17µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 7µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::default_severity |
| 1 | 1 | 1 | 6µs | 6µs | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::supported_parameters |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::violates |
| 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::Subroutines::ProhibitExcessComplexity; | ||||
| 9 | |||||
| 10 | 2 | 39µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@10 which was called:
# once (16µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 16µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@10 |
| 11 | 2 | 19µs | 2 | 28µs | # spent 17µs (7+11) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@11 which was called:
# once (7µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 17µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@11
# spent 11µs making 1 call to strict::import |
| 12 | 2 | 18µs | 2 | 14µs | # spent 11µs (7+4) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::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::Subroutines::ProhibitExcessComplexity::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | 2 | 26µs | 2 | 47µs | # spent 27µs (7+20) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@13 which was called:
# once (7µs+20µs) by Module::Pluggable::Object::_require at line 13 # spent 27µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 25µs | 2 | 862µs | # spent 434µs (7+427) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@15 which was called:
# once (7µs+427µs) by Module::Pluggable::Object::_require at line 15 # spent 434µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@15
# spent 427µs making 1 call to Exporter::import |
| 16 | 2 | 93µs | 2 | 1.15ms | # spent 1.10ms (546µs+559µs) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@16 which was called:
# once (546µs+559µs) by Module::Pluggable::Object::_require at line 16 # spent 1.10ms making 1 call to Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@16
# spent 42µs making 1 call to Exporter::import |
| 17 | |||||
| 18 | 2 | 172µs | 2 | 115µs | # spent 61µs (7+54) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@18 which was called:
# once (7µs+54µs) by Module::Pluggable::Object::_require at line 18 # spent 61µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::BEGIN@18
# spent 54µs making 1 call to base::import |
| 19 | |||||
| 20 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 21 | |||||
| 22 | #----------------------------------------------------------------------------- | ||||
| 23 | |||||
| 24 | 1 | 2µs | 1 | 28µs | Readonly::Scalar my $EXPL => q{Consider refactoring}; # spent 28µs making 1 call to Readonly::Scalar |
| 25 | |||||
| 26 | #----------------------------------------------------------------------------- | ||||
| 27 | |||||
| 28 | # spent 6µs within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::supported_parameters which was called:
# once (6µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
| 29 | return ( | ||||
| 30 | { | ||||
| 31 | 1 | 8µs | name => 'max_mccabe', | ||
| 32 | description => 'The maximum complexity score allowed.', | ||||
| 33 | default_string => '20', | ||||
| 34 | behavior => 'integer', | ||||
| 35 | integer_minimum => 1, | ||||
| 36 | }, | ||||
| 37 | ); | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::Subroutines::ProhibitExcessComplexity::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 complexity maintenance) } | ||||
| 42 | sub applies_to { return 'PPI::Statement::Sub' } | ||||
| 43 | |||||
| 44 | #----------------------------------------------------------------------------- | ||||
| 45 | |||||
| 46 | sub violates { | ||||
| 47 | my ( $self, $elem, undef ) = @_; | ||||
| 48 | |||||
| 49 | my $score = calculate_mccabe_of_sub( $elem ); | ||||
| 50 | |||||
| 51 | # Is it too complex? | ||||
| 52 | return if $score <= $self->{_max_mccabe}; | ||||
| 53 | |||||
| 54 | my $desc; | ||||
| 55 | if ( my $name = $elem->name() ) { | ||||
| 56 | $desc = qq<Subroutine "$name" with high complexity score ($score)>; | ||||
| 57 | } | ||||
| 58 | else { | ||||
| 59 | $desc = qq<Anonymous subroutine with high complexity score ($score)>; | ||||
| 60 | } | ||||
| 61 | |||||
| 62 | return $self->violation( $desc, $EXPL, $elem ); | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | |||||
| 66 | 1 | 3µs | 1; | ||
| 67 | |||||
| 68 | __END__ |