« Perl/Lint/Policy/BuiltinFunctions/ProhibitUniversalCan.pm
↑ Summary
Perl/Lint/Policy/ValuesAndExpressions/ProhibitVersionStrings.pm »
| 1 | package Perl::Lint::Policy::BuiltinFunctions::ProhibitUniversalIsa; | ||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 2 | DESC => 'UNIVERSAL::isa should not be used as a function', | |||||||||||||||||||||||||||||||
| 9 | EXPL => 'Use eval{$obj->isa($pkg)} instead', | ||||||||||||||||||||||||||||||||
| 10 | 2 | }; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 13 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 0 | my @violations; | |||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 17 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||
| 18 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ($token_type == KEY && $token_data eq 'isa') { # for isa() | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$token_type == 122 and $token_data eq "isa"
MC/DC0%0/2
$token_type == 122 and $token_data eq "isa"
$token_type == 122
$token_data eq "isa"
Truth table0%0/3
A and B
A= $token_type == 122B= $token_data eq "isa"
| |||||||||||||||||||||||||||||||||
| 21 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ($token->{type} == LEFT_PAREN) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 23 | push @violations, { | ||||||||||||||||||||||||||||||||
| 24 | filename => $file, | ||||||||||||||||||||||||||||||||
| 25 | line => $token->{line}, | ||||||||||||||||||||||||||||||||
| 26 | 0 | description => DESC, | |||||||||||||||||||||||||||||||
| 27 | explanation => EXPL, | ||||||||||||||||||||||||||||||||
| 28 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||
| 32 | ▶ | elsif ($token_type == NAMESPACE && $token_data eq 'UNIVERSAL') { # for UNIVERSAL::isa() | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$token_type == 127 and $token_data eq "UNIVERSAL"
MC/DC0%0/2
$token_type == 127 and $token_data eq "UNIVERSAL"
$token_type == 127
$token_data eq "UNIVERSAL"
Truth table0%0/3
A and B
A= $token_type == 127B= $token_data eq "UNIVERSAL"
| |||||||||||||||||||||||||||||||||
| 33 | 0 | $i += 2; # skip the name space resolver | |||||||||||||||||||||||||||||||
| 34 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($token->{type} == NAMESPACE && $token->{data} eq 'isa') { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token->{"type"} == 127 and $token->{"data"} eq "isa"
MC/DC0%0/2
$token->{"type"} == 127 and $token->{"data"} eq "isa"
$token->{"type"} == 127
$token->{"data"} eq "isa"
Truth table0%0/3
A and B
A= $token->{"type"} == 127B= $token->{"data"} eq "isa"
| |||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ($tokens->[++$i]->{type} == LEFT_PAREN) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 37 | push @violations, { | ||||||||||||||||||||||||||||||||
| 38 | filename => $file, | ||||||||||||||||||||||||||||||||
| 39 | line => $token->{line}, | ||||||||||||||||||||||||||||||||
| 40 | 0 | description => DESC, | |||||||||||||||||||||||||||||||
| 41 | explanation => EXPL, | ||||||||||||||||||||||||||||||||
| 42 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 0 | return \@violations; | |||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 2 | 1; | |||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||