« Perl/Lint/Policy/ValuesAndExpressions/ProhibitSpecialHeredocTerminator.pm
↑ Summary
Perl/Lint/Policy/RegularExpressions/ProhibitUselessTopic.pm »
| 1 | package Perl::Lint::Policy::Subroutines::ProhibitAmpersandSigils; | ||||||||||||||||||||||||||||||||||||||||||
| 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 => 'Subroutine called with "&" sigil', | |||||||||||||||||||||||||||||||||||||||||
| 9 | EXPL => [175], | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=16 SCAR=35.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my ($class, $file, $tokens, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | my @violations; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | my $is_before_token_function = 0; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | my $is_in_ref = 0; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | my $left_paren_num = 0; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 51 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 51 | ▶ | if ($token_type == BIT_AND) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $next_token_type = $tokens->[++$i]->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$next_token_type == 122 or $next_token_type == 127 or $next_token_type == 126
$next_token_type == 122 or $next_token_type == 127
MC/DC0%0/3
$next_token_type == 122 or $next_token_type == 127 or $next_token_type == 126
$next_token_type == 122
$next_token_type == 127
$next_token_type == 126
Truth table0%0/4
A or B or C
A= $next_token_type == 122B= $next_token_type == 127C= $next_token_type == 126
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | $next_token_type == KEY || | ||||||||||||||||||||||||||||||||||||||||||
| 26 | $next_token_type == NAMESPACE || | ||||||||||||||||||||||||||||||||||||||||||
| 27 | $next_token_type == NAMESPACE_RESOLVER | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if (!$is_before_token_function && !$is_in_ref) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$is_before_token_function or $is_in_ref
MC/DC0%0/2
$is_before_token_function or $is_in_ref
$is_before_token_function
$is_in_ref
Truth table0%0/3
A or B
A= $is_before_token_functionB= $is_in_ref
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||
| 34 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||
| 35 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | ▶ | elsif ($token_type == KEY || $token_type == BUILTIN_FUNC || $token_type == GOTO) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$token_type == 122 or $token_type == 70 or $token_type == 85
$token_type == 122 or $token_type == 70
MC/DC33%1/3
$token_type == 122 or $token_type == 70 or $token_type == 85
$token_type == 122
$token_type == 70
$token_type == 85
Truth table50%2/4
A or B or C
A= $token_type == 122B= $token_type == 70C= $token_type == 85
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | $is_before_token_function = 1; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | elsif ($token_type == REF) { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $is_in_ref = 1; | |||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | elsif ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | $left_paren_num--; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | if ($left_paren_num <= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | $is_in_ref = 0; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 48 | ▶ | if ($left_paren_num <= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 37 | $is_in_ref = 0; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 48 | $is_before_token_function = 0; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||