« Perl/Lint/Policy/ControlStructures/ProhibitPostfixControls.pm
↑ Summary
Perl/Lint/Policy/BuiltinFunctions/ProhibitStringySplit.pm »
| 1 | package Perl::Lint::Policy::Subroutines::ProhibitBuiltinHomonyms; | ||||||||||||||||||||||||||||||||||||||||||
| 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 Perl::Lint::Keywords; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use List::Util qw/any/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | DESC => 'Subroutine name is a homonym for builtin %s %s', | |||||||||||||||||||||||||||||||||||||||||
| 11 | EXPL => [177], | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my ($class, $file, $tokens, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | if ($token_type == FUNCTION_DECL) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ($token->{type} == FUNCTION) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | next if $token_data eq 'import' || $token_data eq 'AUTOLOAD' || $token_data eq 'DESTROY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$token_data eq "import" or $token_data eq "AUTOLOAD" or $token_data eq "DESTROY"
$token_data eq "import" or $token_data eq "AUTOLOAD"
MC/DC0%0/3
$token_data eq "import" or $token_data eq "AUTOLOAD" or $token_data eq "DESTROY"
$token_data eq "import"
$token_data eq "AUTOLOAD"
$token_data eq "DESTROY"
Truth table0%0/4
A or B or C
A= $token_data eq "import"B= $token_data eq "AUTOLOAD"C= $token_data eq "DESTROY"
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $homonym_type; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if (is_perl_builtin($token_data)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $homonym_type = 'function'; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | elsif (is_perl_bareword($token_data)) { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $homonym_type = 'keyword'; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | description => sprintf(DESC, $homonym_type, $token_data), | |||||||||||||||||||||||||||||||||||||||||
| 41 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||