← 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/NamingConventions/ProhibitAmbiguousNames.pm
StatementsExecuted 18 statements in 444µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::BEGIN@10Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@10
11113µs16µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::supported_parametersPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::supported_parameters
1119µs16µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::BEGIN@12Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@12
1118µs35µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::BEGIN@13Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@13
1118µs237µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::BEGIN@15Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@15
1118µs58µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::BEGIN@16Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@16
1117µs18µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::BEGIN@11Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@11
1116µs7µsPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::default_severityPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::default_severity
0000s0sPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::applies_toPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::applies_to
0000s0sPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::default_themesPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::default_themes
0000s0sPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::::violatesPerl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::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::NamingConventions::ProhibitAmbiguousNames;
9
10240µs116µ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
use 5.006001;
11220µs230µ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
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@11 # spent 11µs making 1 call to strict::import
12220µs223µ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
use warnings;
# spent 16µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@12 # spent 7µs making 1 call to warnings::import
13224µs261µ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
use Readonly;
# spent 35µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@13 # spent 26µs making 1 call to Exporter::import
14
15225µs2465µ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
use Perl::Critic::Utils qw{ :severities :data_conversion };
# spent 237µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@15 # spent 228µs making 1 call to Exporter::import
162295µs2108µ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
use base 'Perl::Critic::Policy';
# spent 58µs making 1 call to Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames::BEGIN@16 # spent 50µs making 1 call to base::import
17
181600nsour $VERSION = '1.121';
19
20#-----------------------------------------------------------------------------
21
2213µs149µsReadonly::Scalar my $EXPL => [ 48 ];
# spent 49µs making 1 call to Readonly::Scalar
23
2411µs121µsReadonly::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
sub supported_parameters {
30 return (
31 {
32112µs22µ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
4011µ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
sub default_severity { return $SEVERITY_MEDIUM }
41sub default_themes { return qw(core pbp maintenance) }
42sub applies_to { return qw(PPI::Statement::Sub
43 PPI::Statement::Variable) }
44
45#-----------------------------------------------------------------------------
46
47sub 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
10414µs1;
105
106__END__