| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/ValuesAndExpressions/ProhibitInterpolationOfLiterals.pm |
| Statements | Executed 26 statements in 580µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 19µs | 22µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::supported_parameters |
| 1 | 1 | 1 | 19µs | 19µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@10 |
| 1 | 1 | 1 | 9µs | 161µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@15 |
| 1 | 1 | 1 | 8µs | 12µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@12 |
| 1 | 1 | 1 | 8µs | 58µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@18 |
| 1 | 1 | 1 | 8µs | 29µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 402µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@17 |
| 1 | 1 | 1 | 7µs | 19µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 6µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::_parse_allow |
| 1 | 1 | 1 | 6µs | 7µs | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::default_severity |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::__ANON__[:87] |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::_has_interpolation |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::violates |
| 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::ValuesAndExpressions::ProhibitInterpolationOfLiterals; | ||||
| 9 | |||||
| 10 | 2 | 42µs | 1 | 19µ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 # spent 19µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@10 |
| 11 | 2 | 26µs | 2 | 30µ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 # spent 19µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@11
# spent 12µs making 1 call to strict::import |
| 12 | 2 | 19µs | 2 | 16µ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 # spent 12µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | 2 | 24µs | 2 | 51µ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 # spent 29µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@13
# spent 22µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 28µs | 2 | 314µ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 # spent 161µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@15
# spent 152µs making 1 call to Exporter::Tiny::import |
| 16 | |||||
| 17 | 2 | 26µs | 2 | 797µ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 # spent 402µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@17
# spent 394µs making 1 call to Exporter::import |
| 18 | 2 | 380µs | 2 | 109µ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 # spent 58µs making 1 call to Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals::BEGIN@18
# spent 51µs making 1 call to base::import |
| 19 | |||||
| 20 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 21 | |||||
| 22 | #----------------------------------------------------------------------------- | ||||
| 23 | |||||
| 24 | 1 | 2µs | 1 | 31µs | Readonly::Scalar my $DESC => q{Useless interpolation of literal string}; # spent 31µs making 1 call to Readonly::Scalar |
| 25 | 1 | 2µs | 1 | 2.93ms | Readonly::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 | ||||
| 30 | return ( | ||||
| 31 | { | ||||
| 32 | 1 | 16µs | 2 | 3µ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 | |||||
| 48 | 1 | 2µ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 | ||
| 49 | sub default_themes { return qw( core pbp cosmetic ) } | ||||
| 50 | sub applies_to { return qw(PPI::Token::Quote::Double | ||||
| 51 | PPI::Token::Quote::Interpolate) } | ||||
| 52 | |||||
| 53 | #----------------------------------------------------------------------------- | ||||
| 54 | |||||
| 55 | 1 | 1µs | 1 | 22µs | Readonly::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 | ||||
| 58 | 1 | 600ns | my ($self, $parameter, $config_string) = @_; | ||
| 59 | |||||
| 60 | 1 | 500ns | my @allow; | ||
| 61 | |||||
| 62 | 1 | 700ns | 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 | |||||
| 73 | 1 | 1µs | $self->{_allow} = \@allow; | ||
| 74 | |||||
| 75 | 1 | 6µs | return; | ||
| 76 | } | ||||
| 77 | |||||
| 78 | #----------------------------------------------------------------------------- | ||||
| 79 | |||||
| 80 | sub 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 | |||||
| 100 | sub _has_interpolation { | ||||
| 101 | my $elem = shift; | ||||
| 102 | return $elem =~ m< | ||||
| 103 | (?: \A | [^\\] ) | ||||
| 104 | (?: \\{2} )* | ||||
| 105 | (?: [\$\@] \S+ | \\[tnrfbae0xcNLuLUEQ] ) | ||||
| 106 | >xmso; | ||||
| 107 | } | ||||
| 108 | |||||
| 109 | 1 | 4µs | 1; | ||
| 110 | |||||
| 111 | __END__ |