← 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/ProhibitInterpolationOfLiterals.pm
StatementsExecuted 26 statements in 580µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11119µs22µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::supported_parametersPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::supported_parameters
11119µs19µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@10Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@10
1119µs161µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@15Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@15
1118µs12µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@12Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@12
1118µs58µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@18Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@18
1118µs29µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@13Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@13
1118µs402µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@17Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@17
1117µs19µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::BEGIN@11Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@11
1116µs6µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::_parse_allowPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::_parse_allow
1116µs7µsPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::default_severityPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::default_severity
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::__ANON__[:87]Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::__ANON__[:87]
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::_has_interpolationPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::_has_interpolation
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::applies_toPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::applies_to
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::default_themesPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::default_themes
0000s0sPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::::violatesPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::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::ProhibitInterpolationOfLiterals;
9
10242µs119µs
# spent 19µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@10 which was called: # once (19µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11226µs230µs
# spent 19µs (7+12) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::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::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@11 # spent 12µs making 1 call to strict::import
12219µs216µs
# spent 12µs (8+4) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@12 which was called: # once (8µs+4µs) by Module::Pluggable::Object::_require at line 12
use warnings;
13224µs251µs
# spent 29µs (8+22) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@13 which was called: # once (8µs+22µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
14
15228µs2314µs
# spent 161µs (9+152) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@15 which was called: # once (9µs+152µs) by Module::Pluggable::Object::_require at line 15
use List::MoreUtils qw(any);
16
17226µs2797µs
# spent 402µs (8+394) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@17 which was called: # once (8µs+394µs) by Module::Pluggable::Object::_require at line 17
use Perl::Critic::Utils qw{ :characters :severities :data_conversion };
# spent 402µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@17 # spent 394µs making 1 call to Exporter::import
182380µs2109µs
# spent 58µs (8+51) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@18 which was called: # once (8µs+51µs) by Module::Pluggable::Object::_require at line 18
use base 'Perl::Critic::Policy';
# spent 58µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@18 # spent 51µs making 1 call to base::import
19
201600nsour $VERSION = '1.121';
21
22#-----------------------------------------------------------------------------
23
2412µs131µsReadonly::Scalar my $DESC => q{Useless interpolation of literal string};
# spent 31µs making 1 call to Readonly::Scalar
2512µs12.93msReadonly::Scalar my $EXPL => [51];
# spent 2.93ms making 1 call to Readonly::Scalar
26
27#-----------------------------------------------------------------------------
28
29
# spent 22µs (19+3) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::supported_parameters which was called: # once (19µs+3µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
30 return (
31 {
32116µs23µs name => 'allow',
# spent 3µs making 2 calls to Readonly::Scalar::FETCH, avg 2µs/call
33 description =>
34 'Kinds of delimiters to permit, e.g. "qq{", "qq(", "qq[", "qq/".',
35 default_string => $EMPTY,
36 parser => \&_parse_allow,
37 },
38 {
39 name => 'allow_if_string_contains_single_quote',
40 description =>
41 q<If the string contains ' characters, allow "" to quote it.>,
42 default_string => '0',
43 behavior => 'boolean',
44 },
45 );
46}
47
4812µs
# spent 7µs (6+1) within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::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_LOWEST }
49sub default_themes { return qw( core pbp cosmetic ) }
50sub applies_to { return qw(PPI::Token::Quote::Double
51 PPI::Token::Quote::Interpolate) }
52
53#-----------------------------------------------------------------------------
54
5511µs122µsReadonly::Scalar my $MAX_SPECIFICATION_LENGTH => 3;
# spent 22µs making 1 call to Readonly::Scalar
56
57
# spent 6µs within Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::_parse_allow which was called: # once (6µs+0s) by Perl::Critic::PolicyParameter::parse_and_validate_config_value at line 231 of Perl/Critic/PolicyParameter.pm
sub _parse_allow {
581600ns my ($self, $parameter, $config_string) = @_;
59
601500ns my @allow;
61
621700ns if (defined $config_string) {
63 @allow = words_from_string( $config_string );
64 #Try to be forgiving with the configuration...
65 for (@allow) {
66 m{ \A qq }xms || ($_ = 'qq' . $_)
67 } #Add 'qq'
68 for (@allow) {
69 (length $_ <= $MAX_SPECIFICATION_LENGTH) || chop
70 } #Chop closing char
71 }
72
7311µs $self->{_allow} = \@allow;
74
7516µs return;
76}
77
78#-----------------------------------------------------------------------------
79
80sub violates {
81 my ( $self, $elem, undef ) = @_;
82
83 # Skip if this string needs interpolation
84 return if _has_interpolation($elem);
85
86 # Overlook allowed quote styles
87 return if any { $elem =~ m{ \A \Q$_\E }xms } @{ $self->{_allow} };
88
89 # If the flag is set, allow "I'm here".
90 if ( $self->{_allow_if_string_contains_single_quote} ) {
91 return if index ($elem, $QUOTE) >= 0;
92 }
93
94 # Must be a violation
95 return $self->violation( $DESC, $EXPL, $elem );
96}
97
98#-----------------------------------------------------------------------------
99
100sub _has_interpolation {
101 my $elem = shift;
102 return $elem =~ m<
103 (?: \A | [^\\] )
104 (?: \\{2} )*
105 (?: [\$\@] \S+ | \\[tnrfbae0xcNLuLUEQ] )
106 >xmso;
107}
108
10914µs1;
110
111__END__