« Perl/Lint/Policy/Modules/ProhibitEvilModules.pm
↑ Summary
Perl/Lint/Policy/RegularExpressions/ProhibitUnusualDelimiters.pm »
| 1 | package Perl::Lint::Policy::Variables::ProhibitPerl4PackageNames; | ||||||||||||||||||||||||||||
| 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 => 'Using the obsolete single quote as package separator', | |||||||||||||||||||||||||||
| 9 | EXPL => q{Use double colon (::) to separate package name components instead of single quotes (')}, | ||||||||||||||||||||||||||||
| 10 | 3 | }; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=14 SCAR=44.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 2 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | my @violations; | |||||||||||||||||||||||||||
| 16 | 2 | ▶ | for ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | my $i = 0, my $token_type, my $token_data, my $is_just_before_left_brace = 0; | ||||||||||||||||||||||||||||
| 18 | my $token = $tokens->[$i]; | ||||||||||||||||||||||||||||
| 19 | $i++ | ||||||||||||||||||||||||||||
| 20 | ) { | ||||||||||||||||||||||||||||
| 21 | 51 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 51 | ▶ | if ($token_type == NAMESPACE_RESOLVER) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $is_perl4_package_name = $token->{data} eq q{'} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($token_type == NAMESPACE_RESOLVER) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($token->{data} eq q{'}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | $is_perl4_package_name = 1; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | elsif ($token_type != NAMESPACE) { | ||||||||||||||||||||||||||||
| 35 | 0 | last; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($is_perl4_package_name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if ($is_just_before_left_brace) { # XXX workaround, for example `$foo{ bar'baz }` | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | next; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if ($token && $token->{type} == ARROW) { # XXX workaround, for example `$foo = { bar'baz => 0 }` | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token and $token->{"type"} == 124
MC/DC0%0/2
$token and $token->{"type"} == 124
$token
$token->{"type"} == 124
Truth table0%0/3
A and B
A= $tokenB= $token->{"type"} == 124
| |||||||||||||||||||||||||||||
| 45 | 0 | next; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | push @violations, { | ||||||||||||||||||||||||||||
| 49 | filename => $file, | ||||||||||||||||||||||||||||
| 50 | line => $token->{line}, | ||||||||||||||||||||||||||||
| 51 | 0 | description => DESC, | |||||||||||||||||||||||||||
| 52 | explanation => EXPL, | ||||||||||||||||||||||||||||
| 53 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||
| 54 | }; | ||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | $is_just_before_left_brace = 0; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | elsif ($token_type == LEFT_BRACE) { | ||||||||||||||||||||||||||||
| 60 | 1 | $is_just_before_left_brace = 1; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | elsif ($token_type != NAMESPACE) { | ||||||||||||||||||||||||||||
| 63 | 50 | $is_just_before_left_brace = 0; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 2 | return \@violations; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 3 | 1; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||