← 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/Modules/RequireNoMatchVarsWithUseEnglish.pm
StatementsExecuted 18 statements in 571µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs17µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::BEGIN@10Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@10
1118µs63µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::BEGIN@17Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@17
1117µs29µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::BEGIN@14Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@14
1117µs339µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::BEGIN@16Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@16
1117µs11µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::BEGIN@12Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@12
1117µs19µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::BEGIN@11Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@11
1116µs7µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::default_severityPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::default_severity
1112µs2µsPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::supported_parametersPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::supported_parameters
0000s0sPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::_descend_into_parenthesized_list_if_presentPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::_descend_into_parenthesized_list_if_present
0000s0sPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::_skip_version_numberPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::_skip_version_number
0000s0sPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::applies_toPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::applies_to
0000s0sPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::default_themesPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::default_themes
0000s0sPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::::violatesPerl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::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::Modules::RequireNoMatchVarsWithUseEnglish;
9
10247µs117µs
# spent 17µs within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@10 which was called: # once (17µ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::Modules::RequireNoMatchVarsWithUseEnglish::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::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@11 # spent 12µs making 1 call to strict::import
12222µs215µs
# spent 11µs (7+4) within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::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::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14224µs251µs
# spent 29µs (7+22) within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@14 which was called: # once (7µs+22µs) by Module::Pluggable::Object::_require at line 14
use Readonly;
# spent 29µs making 1 call to Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@14 # spent 22µs making 1 call to Exporter::import
15
16224µs2671µs
# spent 339µs (7+332) within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@16 which was called: # once (7µs+332µs) by Module::Pluggable::Object::_require at line 16
use Perl::Critic::Utils qw< :characters :severities >;
# spent 339µs making 1 call to Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@16 # spent 332µs making 1 call to Exporter::import
172420µs2119µs
# spent 63µs (8+55) within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@17 which was called: # once (8µs+55µs) by Module::Pluggable::Object::_require at line 17
use base 'Perl::Critic::Policy';
# spent 63µs making 1 call to Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::BEGIN@17 # spent 55µs making 1 call to base::import
18
191500nsour $VERSION = '1.121';
20
21#-----------------------------------------------------------------------------
22
2312µs129µsReadonly::Scalar my $EXPL =>
# spent 29µs making 1 call to Readonly::Scalar
24 q{"use English" without the '-no_match_vars' argument degrades performance.'};
251900ns121µsReadonly::Scalar my $DESC => q{"use English" without '-no_match_vars' argument};
# spent 21µs making 1 call to Readonly::Scalar
26
27#-----------------------------------------------------------------------------
28
2914µs
# spent 2µs within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::supported_parameters which was called: # once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters { return () }
3011µs
# spent 7µs (6+1) within Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish::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 }
31sub default_themes { return qw( core performance ) }
32sub applies_to { return 'PPI::Statement::Include' }
33
34#-----------------------------------------------------------------------------
35
36sub violates {
37 my ( $self, $elem, $doc ) = @_;
38
39 # "require"ing English is kind of useless.
40 return if $elem->type() ne 'use';
41 return if $elem->module() ne 'English';
42
43 my @elements = $elem->schildren();
44 shift @elements; # dump "use"
45 shift @elements; # dump "English"
46
47 if (not @elements) {
48 return $self->violation($DESC, $EXPL, $elem);
49 }
50
51 _skip_version_number( \@elements );
52
53 @elements = _descend_into_parenthesized_list_if_present(@elements);
54
55 if (not @elements) {
56 return $self->violation($DESC, $EXPL, $elem);
57 }
58
59 my $current_element = $elements[0];
60
61 while ( $current_element ) {
62 if ( $current_element->isa('PPI::Token::Quote') ) {
63 return if $current_element->string() eq '-no_match_vars';
64 }
65 elsif ( $current_element->isa('PPI::Token::QuoteLike::Words') ) {
66 return if $current_element->content() =~ m/-no_match_vars \b/xms;
67 }
68 elsif (
69 not $current_element->isa('PPI::Token::Operator')
70 or $current_element->content() ne $COMMA
71 and $current_element->content() ne $FATCOMMA
72 ) {
73 return $self->violation($DESC, $EXPL, $elem);
74 }
75
76 shift @elements;
77 $current_element = $elements[0];
78 }
79
80 return $self->violation($DESC, $EXPL, $elem);
81}
82
83
84sub _skip_version_number {
85 my ($elements_ref) = @_;
86
87 my $current_element = $elements_ref->[0];
88
89 if ( $current_element->isa('PPI::Token::Number') ) {
90 shift @{$elements_ref};
91 }
92 elsif (
93 @{$elements_ref} >= 2
94 and $current_element->isa('PPI::Token::Word')
95 and $current_element->content() =~ m/\A v \d+ \z/xms
96 and $elements_ref->[1]->isa('PPI::Token::Number')
97 ) {
98 # The above messy conditional necessary due to PPI not handling
99 # v-strings.
100 shift @{$elements_ref};
101 shift @{$elements_ref};
102 }
103
104 return;
105}
106
107sub _descend_into_parenthesized_list_if_present {
108 my @elements = @_;
109
110 return if not @elements;
111
112 my $current_element = $elements[0];
113
114 if ( $current_element->isa('PPI::Structure::List') ) {
115 my @grand_children = $current_element->schildren();
116 if (not @grand_children) {
117 return;
118 }
119
120 my $grand_child = $grand_children[0];
121
122 if ( $grand_child->isa('PPI::Statement::Expression') ) {
123 my @great_grand_children = $grand_child->schildren();
124
125 if (not @great_grand_children) {
126 return;
127 }
128
129 return @great_grand_children;
130 }
131 else {
132 return @grand_children;
133 }
134 }
135
136 return @elements;
137}
138
13914µs1;
140
141__END__