« Perl/Lint/Policy/ControlStructures/ProhibitLabelsWithSpecialBlockNames.pm
↑ Summary
Perl/Lint/Policy/ValuesAndExpressions/ProhibitLongChainsOfMethodCalls.pm »
| 1 | package Perl::Lint::Policy::RegularExpressions::RequireBracesForMultiline; | ||||||||||||||||||||||||||||
| 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 => 'Use "{" and "}" to delimit multi-line regexps', | |||||||||||||||||||||||||||
| 9 | EXPL => [242], | ||||||||||||||||||||||||||||
| 10 | 3 | }; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=10 SCAR=31.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 2 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | my $brackets_regex = qr/\A\{\Z/; | |||||||||||||||||||||||||||
| 16 | 2 | ▶ | if ($args->{require_braces_for_multiline}->{allow_all_brackets}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | 0 | $brackets_regex = qr/\A[\{\(\[\<]\Z/; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | my @violations; | |||||||||||||||||||||||||||
| 21 | 2 | ▶ | for (my $i = 0, my $token_type; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 51 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 51 | ▶ | if ($token_type == REG_EXP || $token_type == REG_REPLACE_FROM) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$token_type == 187 or $token_type == 156
MC/DC50%1/2
$token_type == 187 or $token_type == 156
$token_type == 187
$token_type == 156
Truth table66%2/3
A or B
A= $token_type == 187B= $token_type == 156
| |||||||||||||||||||||||||||||
| 25 | 2 | ▶ | if (my @backslashes = $token->{data} =~ /(\\*)\n/g) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 0 | my $reg_delim_token = $tokens->[$i-1]; | |||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($reg_delim_token->{data} !~ $brackets_regex) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | for my $backslash (@backslashes) { | |||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (!$backslash || length($backslash) % 2 == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $backslash or length($backslash) % 2 == 0
MC/DC0%0/2
not $backslash or length($backslash) % 2 == 0
not $backslash
length($backslash) % 2 == 0
Truth table0%0/3
not(A) or B
A= not $backslashB= length($backslash) % 2 == 0
| |||||||||||||||||||||||||||||
| 30 | push @violations, { | ||||||||||||||||||||||||||||
| 31 | filename => $file, | ||||||||||||||||||||||||||||
| 32 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 33 | 0 | description => DESC, | |||||||||||||||||||||||||||
| 34 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 35 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||
| 37 | 0 | last; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | return \@violations; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3 | 1; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||