« Perl/Lint/Policy/InputOutput/RequireEncodingWithUTF8Layer.pm
↑ Summary
Perl/Lint/Policy/RegularExpressions/ProhibitComplexRegexes.pm »
| 1 | package Perl::Lint::Policy::TestingAndDebugging::ProhibitNoStrict; | ||||||||||||||||||||||||||||||||||||
| 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 utf8; | ||||||||||||||||||||||||||||||||||
|
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 { | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 9 | 2 | DESC => 'Stricture disabled', | |||||||||||||||||||||||||||||||||||
| 10 | EXPL => [429], | ||||||||||||||||||||||||||||||||||||
| 11 | 2 | }; | |||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||
| 14 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||
| 16 | 0 | my @arg_allows; | |||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | if (my $this_policies_arg = $args->{prohibit_no_strict}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 18 | 0 | ▶ | if (my $allow = $this_policies_arg->{allow}) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 19 | 0 | @arg_allows = map { lc $_ } split(/[\s,]/, $allow); | |||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||
| 23 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||
| 24 | 0 | my $token_num = scalar @$tokens; | |||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | for (my $i = 0; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||
| 27 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($token_type == BUILTIN_FUNC and $token->{data} eq 'no') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 70 and $token->{"data"} eq "no"
MC/DC0%0/2
$token_type == 70 and $token->{"data"} eq "no"
$token_type == 70
$token->{"data"} eq "no"
Truth table0%0/3
A and B
A= $token_type == 70B= $token->{"data"} eq "no"
| |||||||||||||||||||||||||||||||||||||
| 30 | 0 | $token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||
| 32 | 0 | my @allows; | |||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($token->{type} == KEY && $token->{data} eq 'strict') { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token->{"type"} == 122 and $token->{"data"} eq "strict"
MC/DC0%0/2
$token->{"type"} == 122 and $token->{"data"} eq "strict"
$token->{"type"} == 122
$token->{"data"} eq "strict"
Truth table0%0/3
A and B
A= $token->{"type"} == 122B= $token->{"data"} eq "strict"
| |||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | for ($i++; $i < $token_num; $i++) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 35 | 0 | $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||
| 36 | 0 | $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($token_type == STRING || $token_type == RAW_STRING) { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$token_type == 172 or $token_type == 173
MC/DC0%0/2
$token_type == 172 or $token_type == 173
$token_type == 172
$token_type == 173
Truth table0%0/3
A or B
A= $token_type == 172B= $token_type == 173
| |||||||||||||||||||||||||||||||||||||
| 39 | 0 | push @allows, $token->{data}; | |||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||
| 41 | elsif ($token_type == REG_EXP) { | ||||||||||||||||||||||||||||||||||||
| 42 | 0 | push @allows, split(/ /, $token->{data}); | |||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||
| 44 | ▶ | elsif ($token_type == SEMI_COLON || !$tokens->[$i+1]) { | |||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$token_type == 106 or not $$tokens[$i + 1]
MC/DC0%0/2
$token_type == 106 or not $$tokens[$i + 1]
$token_type == 106
not $$tokens[$i + 1]
Truth table0%0/3
A or not(B)
A= $token_type == 106B= not $$tokens[$i + 1]
| |||||||||||||||||||||||||||||||||||||
| 45 | 0 | for my $arg_allow (@arg_allows) { | |||||||||||||||||||||||||||||||||||
| 46 | 0 | @allows = grep { $_ ne $arg_allow } @allows; | |||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if (!@arg_allows || @allows) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not @arg_allows or @allows
MC/DC0%0/2
not @arg_allows or @allows
not @arg_allows
@allows
Truth table0%0/3
not(A) or B
A= not @arg_allowsB= @allows
| |||||||||||||||||||||||||||||||||||||
| 49 | push @violations, { | ||||||||||||||||||||||||||||||||||||
| 50 | filename => $file, | ||||||||||||||||||||||||||||||||||||
| 51 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||
| 52 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||
| 53 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||
| 54 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||
| 55 | }; | ||||||||||||||||||||||||||||||||||||
| 56 | 0 | last; | |||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||
| 64 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||
| 67 | 2 | 1; | |||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||