« Perl/Lint/Policy/TestingAndDebugging/RequireUseStrict.pm
↑ Summary
Perl/Lint/Policy/ControlStructures/ProhibitNegativeExpressionsInUnlessAndUntilConditions.pm »
| 1 | package Perl::Lint::Policy::TestingAndDebugging::RequireUseWarnings; | ||||||||||||||||||||||||||||||||||||||||||
| 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 List::Util qw/any/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use constant EQUIVALENT_PERL_VERSION => 5.005; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | DESC => 'Code before warnings are enabled', | |||||||||||||||||||||||||||||||||||||||||
| 12 | EXPL => [431], | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=15 SCAR=54.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my @marshals = ('warnings', 'Moose', 'Moose::Role', 'Moose::Util::TypeConstraints'); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | if (my $this_policies_arg = $args->{require_use_warnings}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | push @marshals, split / /, ($this_policies_arg->{equivalent_modules} || ''); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$this_policies_arg->{'equivalent_modules'} || ''
MC/DC0%0/1
$this_policies_arg->{'equivalent_modules'} || ''
$this_policies_arg->{'equivalent_modules'}
Truth table0%0/2
A
A= $this_policies_arg->{'equivalent_modules'}
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $token_num = scalar @$tokens; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $is_used_strict = 0; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | TOP: for (my $i = 0; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($token_type == USE_DECL) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $next_token = $tokens->[$i+1]; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($next_token->{type} == DOUBLE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | (my $next_token_data = $next_token->{data}) =~ s/_//g; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($next_token_data == EQUIVALENT_PERL_VERSION) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $used_module = ''; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | for ($i++; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$token_type == 94 or $token_type == 127 or $token_type == 126
$token_type == 94 or $token_type == 127
MC/DC0%0/3
$token_type == 94 or $token_type == 127 or $token_type == 126
$token_type == 94
$token_type == 127
$token_type == 126
Truth table0%0/4
A or B or C
A= $token_type == 94B= $token_type == 127C= $token_type == 126
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | $token_type == USED_NAME || | ||||||||||||||||||||||||||||||||||||||||||
| 47 | $token_type == NAMESPACE || | ||||||||||||||||||||||||||||||||||||||||||
| 48 | $token_type == NAMESPACE_RESOLVER | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $used_module .= $token_data; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (any {$_ eq $used_module} @marshals) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | last TOP; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | next TOP; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($token_type == PACKAGE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | for ($i++; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ($token->{type} == SEMI_COLON) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | next TOP; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||
| 71 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||
| 74 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||