« lib/Perl/Critic/Policy/Variables/ProtectPrivateVars.pm
↑ Summary
lib/Perl/Critic/Exception/Configuration/NonExistentPolicy.pm »
| 1 | package Perl::Critic::Policy::ValuesAndExpressions::ProhibitEscapedCharacters; | ||||||||||
| 2 | |||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 40 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 40 | our $VERSION = '1.156'; | |||||||||
| 12 | |||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||
| 14 | |||||||||||
| 15 | 40 | Readonly::Scalar my $DESC => q{Numeric escapes in interpolated string}; | |||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => [ 54..55 ]; | |||||||||
| 17 | |||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||
| 19 | |||||||||||
| 20 | 90 | ▶ | sub supported_parameters { return () } | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | 74 | ▶ | sub default_severity { return $SEVERITY_LOW } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 83 | ▶ | sub default_themes { return qw(core pbp cosmetic) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 31 | ▶ | sub applies_to { return qw(PPI::Token::Quote::Double | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | PPI::Token::Quote::Interpolate) } | ||||||||||
| 25 | |||||||||||
| 26 | #----------------------------------------------------------------------------- | ||||||||||
| 27 | |||||||||||
| 28 | 1 | ▶ | sub violates { | ||||||||
|
Subroutine
violates: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 29 | 1 | my ( $self, $elem, undef ) = @_; | |||||||||
| 30 | |||||||||||
| 31 | 1 | my $not_escaped = qr/(?<!\\)(?:\\\\)*/xms; | |||||||||
| 32 | 1 | my $hex = qr/\\x[\dA-Fa-f]{2}/xms; | |||||||||
| 33 | 1 | my $widehex = qr/\\x[{][\dA-Fa-f]+[}]/xms; | |||||||||
| 34 | 1 | my $oct = qr/\\[01][0-7]/xms; | |||||||||
| 35 | 1 | ▶ | if ($elem->content =~ m/$not_escaped (?:$hex|$widehex|$oct)/xmso) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||
| 37 | } | ||||||||||
| 38 | 1 | return; #ok! | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 40 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||