« Perl/Lint/Policy/ControlStructures/ProhibitCStyleForLoops.pm
↑ Summary
Perl/Lint/Policy/Subroutines/ProhibitSubroutinePrototypes.pm »
| 1 | package Perl::Lint::Policy::ValuesAndExpressions::ProhibitEscapedCharacters; | ||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 3 | ▶ | use constant { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | DESC => 'Numeric escapes in interpolated string', | |||||||||||||||||||
| 9 | EXPL => [54, 55], | ||||||||||||||||||||
| 10 | 3 | }; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 2 | ▶ | sub evaluate { | ||||||||||||||||||
|
Subroutine
evaluate: called CC=7 SCAR=21.1
Pod
undocumented
| |||||||||||||||||||||
| 13 | 2 | my ($class, $file, $tokens, $args) = @_; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 2 | my @violations; | |||||||||||||||||||
| 16 | 2 | my $is_reg_quote = 0; | |||||||||||||||||||
| 17 | 2 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | 51 | my $token_type = $token->{type}; | |||||||||||||||||||
| 19 | 51 | ▶ | if ($token_type == REG_QUOTE) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 20 | 0 | $is_reg_quote = 1; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | ▶ | elsif ($token_type == STRING || $token_type == REG_EXP) { | |||||||||||||||||||
|
Condition66%2/3
$token_type == 172 or $token_type == 187
MC/DC50%1/2
$token_type == 172 or $token_type == 187
$token_type == 172
$token_type == 187
Truth table66%2/3
A or B
A= $token_type == 172B= $token_type == 187
| |||||||||||||||||||||
| 23 | 2 | ▶ | if ($is_reg_quote) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 0 | $is_reg_quote = 0; | |||||||||||||||||||
| 25 | 0 | next; | |||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 2 | my $string = $token->{data}; | |||||||||||||||||||
| 29 | 2 | ▶ | if ($string =~ /\\x?[0-9a-fA-F]{2,}/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | push @violations, { | ||||||||||||||||||||
| 31 | filename => $file, | ||||||||||||||||||||
| 32 | line => $token->{line}, | ||||||||||||||||||||
| 33 | 0 | description => DESC, | |||||||||||||||||||
| 34 | explanation => EXPL, | ||||||||||||||||||||
| 35 | policy => __PACKAGE__, | ||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 2 | return \@violations; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 3 | 1; | |||||||||||||||||||
| 45 | |||||||||||||||||||||