Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Variables/ProhibitMatchVars.pm |
Statements | Executed 20 statements in 426µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 9µs | 64µs | BEGIN@16 | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 7µs | 31µs | BEGIN@13 | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 7µs | 10µs | BEGIN@12 | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 7µs | 201µs | BEGIN@15 | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::Variables::ProhibitMatchVars::
1 | 1 | 1 | 2µs | 2µs | supported_parameters | Perl::Critic::Policy::Variables::ProhibitMatchVars::
0 | 0 | 0 | 0s | 0s | _is_forbidden_var | Perl::Critic::Policy::Variables::ProhibitMatchVars::
0 | 0 | 0 | 0s | 0s | _is_use_english | Perl::Critic::Policy::Variables::ProhibitMatchVars::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::Variables::ProhibitMatchVars::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::Variables::ProhibitMatchVars::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::Variables::ProhibitMatchVars::
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::ProhibitMatchVars; | ||||
9 | |||||
10 | 2 | 38µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::Variables::ProhibitMatchVars::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::ProhibitMatchVars::BEGIN@10 |
11 | 2 | 19µs | 2 | 30µs | # spent 18µs (7+11) within Perl::Critic::Policy::Variables::ProhibitMatchVars::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::ProhibitMatchVars::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 21µs | 2 | 14µs | # spent 10µs (7+3) within Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@12 which was called:
# once (7µs+3µs) by Module::Pluggable::Object::_require at line 12 # spent 10µs making 1 call to Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 22µs | 2 | 54µs | # spent 31µs (7+24) within Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@13 which was called:
# once (7µs+24µs) by Module::Pluggable::Object::_require at line 13 # spent 31µs making 1 call to Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@13
# spent 24µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 24µs | 2 | 395µs | # spent 201µs (7+194) within Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@15 which was called:
# once (7µs+194µs) by Module::Pluggable::Object::_require at line 15 # spent 201µs making 1 call to Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@15
# spent 194µs making 1 call to Exporter::import |
16 | 2 | 277µs | 2 | 120µs | # spent 64µs (9+55) within Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@16 which was called:
# once (9µs+55µs) by Module::Pluggable::Object::_require at line 16 # spent 64µs making 1 call to Perl::Critic::Policy::Variables::ProhibitMatchVars::BEGIN@16
# spent 56µs making 1 call to base::import |
17 | |||||
18 | 1 | 600ns | our $VERSION = '1.121'; | ||
19 | |||||
20 | #----------------------------------------------------------------------------- | ||||
21 | |||||
22 | 1 | 2µs | 1 | 29µs | Readonly::Scalar my $DESC => q{Match variable used}; # spent 29µs making 1 call to Readonly::Scalar |
23 | 1 | 2µs | 1 | 44µs | Readonly::Scalar my $EXPL => [ 82 ]; # spent 44µs making 1 call to Readonly::Scalar |
24 | |||||
25 | 1 | 1µs | 1 | 22µs | Readonly::Array my @FORBIDDEN => qw( $` $& $' $MATCH $PREMATCH $POSTMATCH ); # spent 22µs making 1 call to Readonly::Array |
26 | 1 | 7µs | 3 | 58µs | Readonly::Hash my %FORBIDDEN => hashify( @FORBIDDEN ); # spent 29µs making 1 call to Readonly::Hash
# spent 28µs making 1 call to Perl::Critic::Utils::hashify
# spent 1µs making 1 call to Readonly::Array::FETCHSIZE |
27 | |||||
28 | #----------------------------------------------------------------------------- | ||||
29 | |||||
30 | 1 | 4µs | # spent 2µs within Perl::Critic::Policy::Variables::ProhibitMatchVars::supported_parameters which was called:
# once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
31 | 1 | 1µs | # spent 7µs (6+1) within Perl::Critic::Policy::Variables::ProhibitMatchVars::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
32 | sub default_themes { return qw( core performance pbp ) } | ||||
33 | sub applies_to { return qw( PPI::Token::Symbol | ||||
34 | PPI::Statement::Include ) } | ||||
35 | |||||
36 | #----------------------------------------------------------------------------- | ||||
37 | |||||
38 | sub violates { | ||||
39 | my ( $self, $elem, undef ) = @_; | ||||
40 | if (_is_use_english($elem) || _is_forbidden_var($elem)) { | ||||
41 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
42 | } | ||||
43 | return; #ok! | ||||
44 | } | ||||
45 | |||||
46 | #----------------------------------------------------------------------------- | ||||
47 | |||||
48 | sub _is_use_english { | ||||
49 | my $elem = shift; | ||||
50 | $elem->isa('PPI::Statement::Include') || return; | ||||
51 | $elem->type() eq 'use' || return; | ||||
52 | $elem->module() eq 'English' || return; | ||||
53 | |||||
54 | # Bare, lacking -no_match_vars. Now handled by | ||||
55 | # Modules::RequireNoMatchVarsWithUseEnglish. | ||||
56 | return 0 if ($elem =~ m/\A use \s+ English \s* ;\z/xms); | ||||
57 | |||||
58 | return 1 if ($elem =~ m/\$(?:PRE|POST|)MATCH/xms); | ||||
59 | return; # either "-no_match_vars" or a specific list | ||||
60 | } | ||||
61 | |||||
62 | sub _is_forbidden_var { | ||||
63 | my $elem = shift; | ||||
64 | $elem->isa('PPI::Token::Symbol') || return; | ||||
65 | return exists $FORBIDDEN{$elem}; | ||||
66 | } | ||||
67 | |||||
68 | 1 | 6µs | 1; | ||
69 | |||||
70 | __END__ |