← 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/Variables/RequireLocalizedPunctuationVars.pm
StatementsExecuted 20 statements in 519µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11116µs16µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::BEGIN@10Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@10
11113µs16µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::supported_parametersPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::supported_parameters
1117µs11µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::BEGIN@12Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@12
1117µs59µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::BEGIN@16Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@16
1117µs18µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::BEGIN@11Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@11
1117µs418µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::BEGIN@15Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@15
1117µs27µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::BEGIN@13Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@13
1116µs7µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::default_severityPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::default_severity
1112µs2µsPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::CORE:qrPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::_is_magic_varPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::_is_magic_var
0000s0sPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::_is_non_local_magic_destPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::_is_non_local_magic_dest
0000s0sPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::applies_toPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::applies_to
0000s0sPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::default_themesPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::default_themes
0000s0sPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::::violatesPerl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::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::Variables::RequireLocalizedPunctuationVars;
9
10242µs116µs
# spent 16µs within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::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::Variables::RequireLocalizedPunctuationVars::BEGIN@11 # spent 11µs making 1 call to strict::import
12218µs214µs
# spent 11µs (7+4) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::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::Variables::RequireLocalizedPunctuationVars::BEGIN@12 # spent 4µs making 1 call to warnings::import
13223µs248µs
# spent 27µs (7+20) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@13 which was called: # once (7µs+20µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 27µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14
15224µs2828µs
# spent 418µs (7+411) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@15 which was called: # once (7µs+411µs) by Module::Pluggable::Object::_require at line 15
use Perl::Critic::Utils qw{ :severities :classification $EMPTY hashify};
# spent 418µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@15 # spent 411µs making 1 call to Exporter::import
162354µs2111µs
# spent 59µs (7+52) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@16 which was called: # once (7µs+52µs) by Module::Pluggable::Object::_require at line 16
use base 'Perl::Critic::Policy';
# spent 59µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@16 # spent 52µs making 1 call to base::import
17
181600nsour $VERSION = '1.121';
19
20#-----------------------------------------------------------------------------
21
22110µs229µsReadonly::Scalar my $PACKAGE_RX => qr/::/xms;
# spent 27µs making 1 call to Readonly::Scalar # spent 2µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::CORE:qr
2313µs231µsReadonly::Hash my %EXCEPTIONS => hashify(qw(
# spent 28µs making 1 call to Readonly::Hash # spent 3µs making 1 call to Perl::Critic::Utils::hashify
24 $_
25 $ARG
26 @_
27));
281900ns122µsReadonly::Scalar my $DESC => q{Magic variable "%s" should be assigned as "local"};
# spent 22µs making 1 call to Readonly::Scalar
2912µs141µsReadonly::Scalar my $EXPL => [ 81, 82 ];
# spent 41µs making 1 call to Readonly::Scalar
30
31#-----------------------------------------------------------------------------
32
33
# spent 16µs (13+2) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::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 {
34 return (
35 {
36111µs22µs name => 'allow',
# spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call
37 description =>
38 q<Global variables to exclude from this policy.>,
39 default_string => $EMPTY,
40 behavior => 'string list',
41 list_always_present_values => [ qw< $_ $ARG @_ > ],
42 },
43 );
44}
45
4612µs
# spent 7µs (6+1) within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::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_HIGH }
47sub default_themes { return qw(core pbp bugs certrec ) }
48sub applies_to { return 'PPI::Token::Operator' }
49
50#-----------------------------------------------------------------------------
51
52sub violates {
53 my ( $self, $elem, undef ) = @_;
54
55 return if $elem ne q{=};
56
57 my $destination = $elem->sprevious_sibling;
58 return if !$destination; # huh? assignment in void context??
59 while ($destination->isa('PPI::Structure::Subscript')) {
60 $destination = $destination->sprevious_sibling()
61 or return;
62 }
63
64 if (my $var = $self->_is_non_local_magic_dest($destination)) {
65 return $self->violation( sprintf( $DESC, $var ), $EXPL, $elem );
66 }
67 return; # OK
68}
69
70sub _is_non_local_magic_dest {
71 my ($self, $elem) = @_;
72
73 # Quick exit if in good form
74 my $modifier = $elem->sprevious_sibling;
75 return
76 if
77 $modifier
78 && $modifier->isa('PPI::Token::Word')
79 && ($modifier eq 'local' || $modifier eq 'my');
80
81 # Implementation note: Can't rely on PPI::Token::Magic,
82 # unfortunately, because we need English too
83
84 if ($elem->isa('PPI::Token::Symbol')) {
85 return $self->_is_magic_var($elem) ? $elem : undef;
86 }
87 elsif (
88 $elem->isa('PPI::Structure::List')
89 or $elem->isa('PPI::Statement::Expression')
90 ) {
91 for my $child ($elem->schildren) {
92 my $var = $self->_is_non_local_magic_dest($child);
93 return $var if $var;
94 }
95 }
96
97 return;
98}
99
100#-----------------------------------------------------------------------------
101
102sub _is_magic_var {
103 my ($self, $elem) = @_;
104
105 my $variable_name = $elem->symbol();
106 return if $self->{_allow}{$variable_name};
107 return 1 if $elem->isa('PPI::Token::Magic'); # optimization(?), and
108 # helps with PPI 1.118 carat
109 # bug. This bug is gone as of
110 # 1.208, which is required for
111 # P::C 1.113. RT 65514
112 return if not is_perl_global( $elem );
113
114 return 1;
115}
116
117110µs1;
118
119__END__
 
# spent 2µs within Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::CORE:qr which was called: # once (2µs+0s) by Module::Pluggable::Object::_require at line 22
sub Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::CORE:qr; # opcode