| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/NamingConventions/ProhibitAmbiguousNames.pm |
| Statements | Executed 18 statements in 444µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 16µs | 16µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@10 |
| 1 | 1 | 1 | 13µs | 16µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::supported_parameters |
| 1 | 1 | 1 | 9µs | 16µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@12 |
| 1 | 1 | 1 | 8µs | 35µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 237µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@15 |
| 1 | 1 | 1 | 8µs | 58µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@16 |
| 1 | 1 | 1 | 7µs | 18µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 7µs | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::default_severity |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::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::NamingConventions::ProhibitAmbiguousNames; | ||||
| 9 | |||||
| 10 | 2 | 40µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::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::NamingConventions::ProhibitAmbiguousNames::BEGIN@10 |
| 11 | 2 | 20µs | 2 | 30µs | # spent 18µs (7+11) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::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::NamingConventions::ProhibitAmbiguousNames::BEGIN@11
# spent 11µs making 1 call to strict::import |
| 12 | 2 | 20µs | 2 | 23µs | # spent 16µs (9+7) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@12 which was called:
# once (9µs+7µs) by Module::Pluggable::Object::_require at line 12 # spent 16µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@12
# spent 7µs making 1 call to warnings::import |
| 13 | 2 | 24µs | 2 | 61µs | # spent 35µs (8+26) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@13 which was called:
# once (8µs+26µs) by Module::Pluggable::Object::_require at line 13 # spent 35µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@13
# spent 26µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 25µs | 2 | 465µs | # spent 237µs (8+228) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@15 which was called:
# once (8µs+228µs) by Module::Pluggable::Object::_require at line 15 # spent 237µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@15
# spent 228µs making 1 call to Exporter::import |
| 16 | 2 | 295µs | 2 | 108µs | # spent 58µs (8+50) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@16 which was called:
# once (8µs+50µs) by Module::Pluggable::Object::_require at line 16 # spent 58µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@16
# spent 50µs making 1 call to base::import |
| 17 | |||||
| 18 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 19 | |||||
| 20 | #----------------------------------------------------------------------------- | ||||
| 21 | |||||
| 22 | 1 | 3µs | 1 | 49µs | Readonly::Scalar my $EXPL => [ 48 ]; # spent 49µs making 1 call to Readonly::Scalar |
| 23 | |||||
| 24 | 1 | 1µs | 1 | 21µs | Readonly::Scalar my $DEFAULT_FORBID => # spent 21µs making 1 call to Readonly::Scalar |
| 25 | 'abstract bases close contract last left no record right second set'; | ||||
| 26 | |||||
| 27 | #----------------------------------------------------------------------------- | ||||
| 28 | |||||
| 29 | # spent 16µs (13+2) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::supported_parameters which was called:
# once (13µs+2µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
| 30 | return ( | ||||
| 31 | { | ||||
| 32 | 1 | 12µs | 2 | 2µs | name => 'forbid', # spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call |
| 33 | description => 'The variable names that are not to be allowed.', | ||||
| 34 | default_string => $DEFAULT_FORBID, | ||||
| 35 | behavior => 'string list', | ||||
| 36 | }, | ||||
| 37 | ); | ||||
| 38 | } | ||||
| 39 | |||||
| 40 | 1 | 1µs | # spent 7µs (6+1) within Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::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) } | ||||
| 42 | sub applies_to { return qw(PPI::Statement::Sub | ||||
| 43 | PPI::Statement::Variable) } | ||||
| 44 | |||||
| 45 | #----------------------------------------------------------------------------- | ||||
| 46 | |||||
| 47 | sub violates { | ||||
| 48 | my ( $self, $elem, undef ) = @_; | ||||
| 49 | |||||
| 50 | if ( $elem->isa('PPI::Statement::Sub') ) { | ||||
| 51 | my @words = grep { $_->isa('PPI::Token::Word') } $elem->schildren(); | ||||
| 52 | for my $word (@words) { | ||||
| 53 | |||||
| 54 | # strip off any leading "Package::" | ||||
| 55 | my ($name) = $word =~ m/ (\w+) \z /xms; | ||||
| 56 | next if not defined $name; # should never happen, right? | ||||
| 57 | |||||
| 58 | if ( exists $self->{_forbid}->{$name} ) { | ||||
| 59 | return $self->violation( | ||||
| 60 | qq<Ambiguously named subroutine "$name">, | ||||
| 61 | $EXPL, | ||||
| 62 | $elem, | ||||
| 63 | ); | ||||
| 64 | } | ||||
| 65 | } | ||||
| 66 | return; # ok | ||||
| 67 | } | ||||
| 68 | |||||
| 69 | # PPI::Statement::Variable | ||||
| 70 | |||||
| 71 | # Accumulate them since there can be more than one violation | ||||
| 72 | # per variable statement | ||||
| 73 | my @violations; | ||||
| 74 | |||||
| 75 | # TODO: false positive bug - this can erroneously catch the | ||||
| 76 | # assignment half of a variable statement | ||||
| 77 | |||||
| 78 | my $symbols = $elem->find('PPI::Token::Symbol'); | ||||
| 79 | if ($symbols) { # this should always be true, right? | ||||
| 80 | for my $symbol ( @{$symbols} ) { | ||||
| 81 | |||||
| 82 | # Strip off sigil and any leading "Package::" | ||||
| 83 | # Beware that punctuation vars may have no | ||||
| 84 | # alphanumeric characters. | ||||
| 85 | |||||
| 86 | my ($name) = $symbol =~ m/ (\w+) \z /xms; | ||||
| 87 | next if ! defined $name; | ||||
| 88 | |||||
| 89 | if ( exists $self->{_forbid}->{$name} ) { | ||||
| 90 | push | ||||
| 91 | @violations, | ||||
| 92 | $self->violation( | ||||
| 93 | qq<Ambiguously named variable "$name">, | ||||
| 94 | $EXPL, | ||||
| 95 | $elem, | ||||
| 96 | ); | ||||
| 97 | } | ||||
| 98 | } | ||||
| 99 | } | ||||
| 100 | |||||
| 101 | return @violations; | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | 1 | 4µs | 1; | ||
| 105 | |||||
| 106 | __END__ |