← 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:11 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Subroutines/ProhibitAmpersandSigils.pm
StatementsExecuted 20 statements in 438µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::BEGIN@10Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@10
1118µs12µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::BEGIN@12Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@12
1118µs29µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::BEGIN@14Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@14
1118µs174µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::BEGIN@16Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@16
1117µs19µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::BEGIN@11Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@11
1117µs59µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::BEGIN@17Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@17
1116µs7µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::default_severityPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::default_severity
1113µs3µsPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::supported_parametersPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::supported_parameters
0000s0sPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::applies_toPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::applies_to
0000s0sPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::default_themesPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::default_themes
0000s0sPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::::violatesPerl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::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::Subroutines::ProhibitAmpersandSigils;
9
10240µs116µs
# spent 16µs within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11221µs230µs
# spent 19µs (7+12) within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@11 which was called: # once (7µs+12µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@11 # spent 12µs making 1 call to strict::import
12224µs215µs
# spent 12µs (8+4) within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
# spent 12µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14224µs250µs
# spent 29µs (8+21) within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@14 which was called: # once (8µs+21µs) by Module::Pluggable::Object::_require at line 14
use Readonly;
# spent 29µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@14 # spent 21µs making 1 call to Exporter::import
15
16224µs2342µs
# spent 174µs (8+167) within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@16 which was called: # once (8µs+167µs) by Module::Pluggable::Object::_require at line 16
use Perl::Critic::Utils qw{ :severities hashify };
# spent 174µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@16 # spent 167µs making 1 call to Exporter::import
172284µs2111µs
# spent 59µs (7+52) within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@17 which was called: # once (7µs+52µs) by Module::Pluggable::Object::_require at line 17
use base 'Perl::Critic::Policy';
# spent 59µs making 1 call to Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::BEGIN@17 # spent 52µs making 1 call to base::import
18
191600nsour $VERSION = '1.121';
20
21#-----------------------------------------------------------------------------
22
2312µs130µsReadonly::Scalar my $DESC => q{Subroutine called with "&" sigil};
# spent 30µs making 1 call to Readonly::Scalar
2412µs144µsReadonly::Scalar my $EXPL => [ 175 ];
# spent 44µs making 1 call to Readonly::Scalar
25
2613µs231µsReadonly::Hash my %EXEMPTIONS =>
# spent 27µs making 1 call to Readonly::Hash # spent 4µs making 1 call to Perl::Critic::Utils::hashify
27 hashify( qw< defined exists goto sort > );
28
2912µs223µsReadonly::Hash my %IS_COMMA =>
# spent 21µs making 1 call to Readonly::Hash # spent 2µs making 1 call to Perl::Critic::Utils::hashify
30 hashify( q{,}, q{=>} );
31
32#-----------------------------------------------------------------------------
33
3416µs
# spent 3µs within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::supported_parameters which was called: # once (3µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return () }
3511µs
# spent 7µs (6+1) within Perl::Critic::Policy::Subroutines::ProhibitAmpersandSigils::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_LOW }
36sub default_themes { return qw(core pbp maintenance) }
37sub applies_to { return 'PPI::Token::Symbol' }
38
39#-----------------------------------------------------------------------------
40
41sub violates {
42 my ( $self, $elem, undef ) = @_;
43
44 my $previous = $elem->sprevious_sibling();
45 if ( $previous ) {
46 #Sigil is allowed if taking a reference, e.g. "\&my_sub"
47 return if $previous->isa('PPI::Token::Cast') && $previous eq q{\\};
48 }
49
50 return if ( $elem !~ m{\A [&] }xms ); # ok
51
52 # look up past parens to get say the "defined" in "defined(&foo)" or
53 # "defined((&foo))" etc
54 if (not $previous or
55 $previous->isa( 'PPI::Token::Operator' ) and
56 $IS_COMMA{ $previous->content() } ) {
57 my $up = $elem;
58
59 PARENT:
60 while (
61 ($up = $up->parent)
62 and (
63 $up->isa('PPI::Statement::Expression')
64 or $up->isa('PPI::Structure::List')
65 or $up->isa('PPI::Statement')
66 )
67 ) {
68 if (my $word = $up->sprevious_sibling) {
69 # Since backslashes distribute over lists (per perlref), if
70 # we have a list and the previous is a backslash, we're cool.
71 return if
72 $up->isa('PPI::Structure::List')
73 && $word->isa('PPI::Token::Cast')
74 && $word->content() eq q{\\};
75
76 # For a word set $previous to have it checked against %EXEMPTIONS
77 # below. For a non-word it's a violation, leave $previous false
78 # to get there.
79 if ($word->isa('PPI::Token::Word')) {
80 $previous = $word;
81 }
82 last PARENT;
83 }
84 }
85 }
86 return if $previous and $EXEMPTIONS{$previous};
87
88 return $self->violation( $DESC, $EXPL, $elem );
89}
90
9115µs1;
92
93__END__