Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Variables/RequireLocalizedPunctuationVars.pm |
Statements | Executed 20 statements in 519µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 13µs | 16µs | supported_parameters | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 7µs | 59µs | BEGIN@16 | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 7µs | 418µs | BEGIN@15 | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 7µs | 27µs | BEGIN@13 | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
1 | 1 | 1 | 2µs | 2µs | CORE:qr (opcode) | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
0 | 0 | 0 | 0s | 0s | _is_magic_var | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
0 | 0 | 0 | 0s | 0s | _is_non_local_magic_dest | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::
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::Variables::RequireLocalizedPunctuationVars; | ||||
9 | |||||
10 | 2 | 42µs | 1 | 16µ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 # spent 16µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@10 |
11 | 2 | 20µs | 2 | 29µ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 # spent 18µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::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::Variables::RequireLocalizedPunctuationVars::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::Variables::RequireLocalizedPunctuationVars::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 23µs | 2 | 48µ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 # spent 27µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 24µs | 2 | 828µ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 # spent 418µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@15
# spent 411µs making 1 call to Exporter::import |
16 | 2 | 354µs | 2 | 111µ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 # spent 59µs making 1 call to Perl::Critic::Policy::Variables::RequireLocalizedPunctuationVars::BEGIN@16
# spent 52µs making 1 call to base::import |
17 | |||||
18 | 1 | 600ns | our $VERSION = '1.121'; | ||
19 | |||||
20 | #----------------------------------------------------------------------------- | ||||
21 | |||||
22 | 1 | 10µs | 2 | 29µs | Readonly::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 |
23 | 1 | 3µs | 2 | 31µs | Readonly::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 | )); | ||||
28 | 1 | 900ns | 1 | 22µs | Readonly::Scalar my $DESC => q{Magic variable "%s" should be assigned as "local"}; # spent 22µs making 1 call to Readonly::Scalar |
29 | 1 | 2µs | 1 | 41µs | Readonly::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 | ||||
34 | return ( | ||||
35 | { | ||||
36 | 1 | 11µs | 2 | 2µ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 | |||||
46 | 1 | 2µ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 | ||
47 | sub default_themes { return qw(core pbp bugs certrec ) } | ||||
48 | sub applies_to { return 'PPI::Token::Operator' } | ||||
49 | |||||
50 | #----------------------------------------------------------------------------- | ||||
51 | |||||
52 | sub 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 | |||||
70 | sub _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 | |||||
102 | sub _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 | |||||
117 | 1 | 10µs | 1; | ||
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 |