« Perl/Lint/Policy/InputOutput/ProhibitBarewordFileHandles.pm
↑ Summary
Perl/Lint/Policy/ClassHierarchies/ProhibitExplicitISA.pm »
| 1 | package Perl::Lint::Policy::Objects::IndirectSyntax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 List::Util 1.38 qw/any/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | DESC => 'Subroutine "%s" called using indirect syntax', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | EXPL => [349], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=10 SCAR=33.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | my @forbidden = ('new'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | my $forbid_arg = $args->{indirect_syntax}->{forbid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | if ($forbid_arg && ref $forbid_arg eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$forbid_arg and ref $forbid_arg eq "ARRAY"
MC/DC0%0/2
$forbid_arg and ref $forbid_arg eq "ARRAY"
$forbid_arg
ref $forbid_arg eq "ARRAY"
Truth table33%1/3
A and B
A= $forbid_argB= ref $forbid_arg eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | push @forbidden, @{$forbid_arg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | my @violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | my $token_num = scalar @$tokens; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | for (my $i = 0; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 51 | my $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 51 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($token->{type} == KEY && any { $token_data eq $_ } @forbidden) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.7
Branch: 1 branch
Condition33%1/3
$token->{"type"} == 122 and &any(sub {
$token_data eq $_;
}
, @forbidden)
MC/DC0%0/2
$token->{"type"} == 122 and &any(sub {
$token_data eq $_;
}
, @forbidden)
$token->{"type"} == 122
&any(sub {
$token_data eq $_;
}
, @forbidden)
Truth table33%1/3
A and B
A= $token->{"type"} == 122B= &any(sub {
$token_data eq $_;
}
, @forbidden)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $token_type = $tokens->[++$i]->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($token_type == KEY || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$token_type == 122 or $token_type == 194 or $token_type == 166 or $token_type == 109
$token_type == 122 or $token_type == 194 or $token_type == 166
$token_type == 122 or $token_type == 194
MC/DC0%0/4
$token_type == 122 or $token_type == 194 or $token_type == 166 or $token_type == 109
$token_type == 122
$token_type == 194
$token_type == 166
$token_type == 109
Truth table0%0/5
A or B or C or D
A= $token_type == 122B= $token_type == 194C= $token_type == 166D= $token_type == 109
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | $token_type == GLOBAL_VAR || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | $token_type == VAR || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | $token_type == LEFT_BRACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | description => sprintf(DESC, $token_data), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | explanation => sprintf(EXPL, $token_data), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||