← 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/ValuesAndExpressions/ProhibitQuotesAsQuotelikeOperatorDelimiters.pm
StatementsExecuted 20 statements in 774µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111109µs154µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::supported_parametersPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::supported_parameters
11116µs16µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::BEGIN@10Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@10
11110µs61µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::BEGIN@18Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@18
1118µs12µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::BEGIN@12Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@12
1118µs28µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::BEGIN@13Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@13
1117µs18µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::BEGIN@11Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@11
1117µs418µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::BEGIN@15Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@15
1116µs7µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::default_severityPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::default_severity
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_allowed_operators_by_delimiterPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_allowed_operators_by_delimiter
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_back_quote_allowed_operatorsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_back_quote_allowed_operators
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_double_quote_allowed_operatorsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_double_quote_allowed_operators
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_info_for_matchPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_info_for_match
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_info_for_single_character_operatorPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_info_for_single_character_operator
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_info_for_transliteratePerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_info_for_transliterate
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_info_for_two_character_operatorPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_info_for_two_character_operator
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::_single_quote_allowed_operatorsPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::_single_quote_allowed_operators
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::applies_toPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::applies_to
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::default_themesPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::default_themes
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::initialize_if_enabledPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::initialize_if_enabled
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::::violatesPerl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::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::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters;
9
10242µs116µs
# spent 16µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@10 which was called: # once (16µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11224µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
12219µs216µs
# spent 12µs (8+4) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
13224µs248µs
# spent 28µs (8+20) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@13 which was called: # once (8µs+20µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
14
151300ns
# spent 418µs (7+411) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@15 which was called: # once (7µs+411µs) by Module::Pluggable::Object::_require at line 17
use Perl::Critic::Utils qw{
16 :booleans :characters :severities :data_conversion
17127µs2828µs};
182552µs2112µs
# spent 61µs (10+51) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::BEGIN@18 which was called: # once (10µs+51µs) by Module::Pluggable::Object::_require at line 18
use base 'Perl::Critic::Policy';
19
201600nsour $VERSION = '1.121';
21
22#-----------------------------------------------------------------------------
23
2412µs146µsReadonly::Hash my %DESCRIPTIONS => (
# spent 46µs making 1 call to Readonly::Hash
25 $QUOTE => q{Single-quote used as quote-like operator delimiter},
26 $DQUOTE => q{Double-quote used as quote-like operator delimiter},
27 $BACKTICK => q{Back-quote (back-tick) used as quote-like operator delimiter},
28);
29
3011µs123µsReadonly::Scalar my $EXPL =>
# spent 23µs making 1 call to Readonly::Scalar
31 q{Using quotes as delimiters for quote-like operators obfuscates code};
32
3311µs123µsReadonly::Array my @OPERATORS => qw{ m q qq qr qw qx s tr y };
# spent 23µs making 1 call to Readonly::Array
34
3512µs129µsReadonly::Hash my %INFO_RETRIEVERS_BY_PPI_CLASS => (
# spent 29µs making 1 call to Readonly::Hash
36 'PPI::Token::Quote::Literal' => \&_info_for_single_character_operator,
37 'PPI::Token::Quote::Interpolate' => \&_info_for_two_character_operator,
38 'PPI::Token::QuoteLike::Command' => \&_info_for_two_character_operator,
39 'PPI::Token::QuoteLike::Regexp' => \&_info_for_two_character_operator,
40 'PPI::Token::QuoteLike::Words' => \&_info_for_two_character_operator,
41 'PPI::Token::Regexp::Match' => \&_info_for_match,
42 'PPI::Token::Regexp::Substitute' => \&_info_for_single_character_operator,
43 'PPI::Token::Regexp::Transliterate' => \&_info_for_transliterate,
44);
45
46#-----------------------------------------------------------------------------
47
48
# spent 154µs (109+45) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::supported_parameters which was called: # once (109µs+45µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
49 return (
50 {
51169µs3445µs name => 'single_quote_allowed_operators',
# spent 37µs making 27 calls to Readonly::Array::FETCH, avg 1µs/call # spent 4µs making 4 calls to Readonly::Scalar::FETCH, avg 1µs/call # spent 4µs making 3 calls to Readonly::Array::FETCHSIZE, avg 1µs/call
52 description =>
53 'The operators to allow single-quotes as delimiters for.',
54 default_string => 'm s qr qx',
55 behavior => 'enumeration',
56 enumeration_values => [ @OPERATORS ],
57 enumeration_allow_multiple_values => 1,
58 },
59 {
60 name => 'double_quote_allowed_operators',
61 description =>
62 'The operators to allow double-quotes as delimiters for.',
63 default_string => $EMPTY,
64 behavior => 'enumeration',
65 enumeration_values => [ @OPERATORS ],
66 enumeration_allow_multiple_values => 1,
67 },
68 {
69 name => 'back_quote_allowed_operators',
70 description =>
71 'The operators to allow back-quotes (back-ticks) as delimiters for.',
72 default_string => $EMPTY,
73 behavior => 'enumeration',
74 enumeration_values => [ @OPERATORS ],
75 enumeration_allow_multiple_values => 1,
76 },
77 );
78}
79
8012µs
# spent 7µs (6+1) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitQuotesAsQuotelikeOperatorDelimiters::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_MEDIUM }
81sub default_themes { return qw( core maintenance ) }
82
83sub applies_to {
84 return qw{
85 PPI::Token::Quote::Interpolate
86 PPI::Token::Quote::Literal
87 PPI::Token::QuoteLike::Command
88 PPI::Token::QuoteLike::Regexp
89 PPI::Token::QuoteLike::Words
90 PPI::Token::Regexp::Match
91 PPI::Token::Regexp::Substitute
92 PPI::Token::Regexp::Transliterate
93 };
94}
95
96#-----------------------------------------------------------------------------
97
98sub initialize_if_enabled {
99 my ($self, $config) = @_;
100
101 $self->{_allowed_operators_by_delimiter} = {
102 $QUOTE => $self->_single_quote_allowed_operators(),
103 $DQUOTE => $self->_double_quote_allowed_operators(),
104 $BACKTICK => $self->_back_quote_allowed_operators(),
105 };
106
107 return $TRUE;
108}
109
110#-----------------------------------------------------------------------------
111
112sub _single_quote_allowed_operators {
113 my ( $self ) = @_;
114
115 return $self->{_single_quote_allowed_operators};
116}
117
118sub _double_quote_allowed_operators {
119 my ( $self ) = @_;
120
121 return $self->{_double_quote_allowed_operators};
122}
123
124sub _back_quote_allowed_operators {
125 my ( $self ) = @_;
126
127 return $self->{_back_quote_allowed_operators};
128}
129
130sub _allowed_operators_by_delimiter {
131 my ( $self ) = @_;
132
133 return $self->{_allowed_operators_by_delimiter};
134}
135
136#-----------------------------------------------------------------------------
137
138sub violates {
139 my ( $self, $elem, undef ) = @_;
140
141 my $info_retriever = $INFO_RETRIEVERS_BY_PPI_CLASS{ ref $elem };
142 return if not $info_retriever;
143
144 my ($operator, $delimiter) = $info_retriever->( $elem );
145
146 my $allowed_operators =
147 $self->_allowed_operators_by_delimiter()->{$delimiter};
148 return if not $allowed_operators;
149
150 if ( not $allowed_operators->{$operator} ) {
151 return $self->violation( $DESCRIPTIONS{$delimiter}, $EXPL, $elem );
152 }
153
154 return;
155}
156
157#-----------------------------------------------------------------------------
158
159sub _info_for_single_character_operator {
160 my ( $elem ) = @_;
161
162 ## no critic (ProhibitParensWithBuiltins)
163 return ( substr ($elem, 0, 1), substr ($elem, 1, 1) );
164 ## use critic
165}
166
167#-----------------------------------------------------------------------------
168
169sub _info_for_two_character_operator {
170 my ( $elem ) = @_;
171
172 ## no critic (ProhibitParensWithBuiltins)
173 return ( substr ($elem, 0, 2), substr ($elem, 2, 1) );
174 ## use critic
175}
176
177#-----------------------------------------------------------------------------
178
179sub _info_for_match {
180 my ( $elem ) = @_;
181
182 if ( $elem =~ m/ ^ m /xms ) {
183 return ('m', substr $elem, 1, 1);
184 }
185
186 return ('m', q{/});
187}
188
189#-----------------------------------------------------------------------------
190
191sub _info_for_transliterate {
192 my ( $elem ) = @_;
193
194 if ( $elem =~ m/ ^ tr /xms ) {
195 return ('tr', substr $elem, 2, 1);
196 }
197
198 return ('y', substr $elem, 1, 1);
199}
200
201
20218µs1;
203
204__END__