« Perl/Lint/Policy/Subroutines/RequireArgUnpacking.pm
↑ Summary
Perl/Lint/Policy/ValuesAndExpressions/RequireConstantVersion.pm »
| 1 | package Perl::Lint::Policy::ControlStructures::ProhibitUnreachableCode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 => 'Unreachable code', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | EXPL => 'Consider removing it', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | my %control_statement_token_types_to_exit = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | &RETURN => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | &NEXT => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | &LAST => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | &REDO => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | my %control_statement_to_exit = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | die => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | exit => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | croak => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | confess => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | my %conditional_token_types = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | &AND => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | &OR => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | &ALPHABET_AND => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | &ALPHABET_OR => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub evaluate { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=36 SCAR=71.9
Pod
undocumented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $depth = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my %is_exited_by_depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | my %unreachable_token_by_depth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my %is_in_ignore_context_by_depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my @violations; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | for (my $i = 0, my $token_type, my $token_data; my $token = $tokens->[$i]; $i++) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $token_type = $token->{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $token_data = $token->{data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($token_type == LEFT_BRACE) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $depth++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if ($token_type == RIGHT_BRACE) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if (my $unreachable_token = $unreachable_token_by_depth{$depth}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | push @violations, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | filename => $file, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | line => $unreachable_token->{line}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | description => DESC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | explanation => EXPL, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | policy => __PACKAGE__, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | undef $unreachable_token_by_depth{$depth}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $is_exited_by_depth{$depth} = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $is_in_ignore_context_by_depth{$depth} = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $depth--; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$token_type == 122 || $token_type == 70 and $control_statement_to_exit{$token_data} or $control_statement_token_types_to_exit{$token_type}
$token_type == 122 || $token_type == 70 and $control_statement_to_exit{$token_data}
$token_type == 122 or $token_type == 70
MC/DC0%0/4
$token_type == 122 || $token_type == 70 and $control_statement_to_exit{$token_data} or $control_statement_token_types_to_exit{$token_type}
$token_type == 122
$token_type == 70
$control_statement_to_exit{$token_data}
$control_statement_token_types_to_exit{$token_type}
Truth table0%0/8
A or B and C or D
A= $token_type == 122B= $token_type == 70C= $control_statement_to_exit{$token_data}D= $control_statement_token_types_to_exit{$token_type}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | (($token_type == KEY || $token_type == BUILTIN_FUNC) && $control_statement_to_exit{$token_data}) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | $control_statement_token_types_to_exit{$token_type} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($is_exited_by_depth{$depth}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $unreachable_token_by_depth{$depth} //= $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$unreachable_token_by_depth{$depth} //= $token
MC/DC0%0/2
$unreachable_token_by_depth{$depth} //= $token
$unreachable_token_by_depth{$depth}
$token
Truth table0%0/3
A //= B
A= $unreachable_token_by_depth{$depth}B= $token
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $before_token = $tokens->[$i-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($conditional_token_types{$before_token->{type}} || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$conditional_token_types{$before_token->{"type"}} or $before_token->{"type"} == 60 and $before_token->{"data"} eq "//"
$before_token->{"type"} == 60 and $before_token->{"data"} eq "//"
MC/DC0%0/3
$conditional_token_types{$before_token->{"type"}} or $before_token->{"type"} == 60 and $before_token->{"data"} eq "//"
$conditional_token_types{$before_token->{"type"}}
$before_token->{"type"} == 60
$before_token->{"data"} eq "//"
Truth table0%0/4
A or B and C
A= $conditional_token_types{$before_token->{"type"}}B= $before_token->{"type"} == 60C= $before_token->{"data"} eq "//"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ($before_token->{type} == DEFAULT_OP && $before_token->{data} eq '//') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # if before token is conditional operator, ignore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $is_exited_by_depth{$depth} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $token_type = $token->{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ($token_type == SEMI_COLON) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($token_type == IF_STATEMENT || $token_type == UNLESS_STATEMENT) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 96 or $token_type == 99
MC/DC0%0/2
$token_type == 96 or $token_type == 99
$token_type == 96
$token_type == 99
Truth table0%0/3
A or B
A= $token_type == 96B= $token_type == 99
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # if postfix conditional statement exists, ignore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $is_exited_by_depth{$depth} = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ($token_type == KEY) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $token = $tokens->[++$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ($token->{type} == COLON) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Label (e.g. FOO:) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $is_in_ignore_context_by_depth{$depth} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($token_type == PACKAGE) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # in other package | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $is_in_ignore_context_by_depth{$depth} = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$token_type == 93 or $token_type == 91 or $token_type == 70 and $token_data eq "no"
$token_type == 93 or $token_type == 91
$token_type == 70 and $token_data eq "no"
MC/DC0%0/4
$token_type == 93 or $token_type == 91 or $token_type == 70 and $token_data eq "no"
$token_type == 93
$token_type == 91
$token_type == 70
$token_data eq "no"
Truth table0%0/5
A or B or C and D
A= $token_type == 93B= $token_type == 91C= $token_type == 70D= $token_data eq "no"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | $token_type == USE_DECL || $token_type == OUR_DECL || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ($token_type == BUILTIN_FUNC && $token_data eq 'no') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # for compiler phase. Ignore them. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $token_type = $token->{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ($token_type == SEMI_COLON) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$token_type == 63 or $token_type == 75 and $token_data eq "BEGIN"
$token_type == 75 and $token_data eq "BEGIN"
MC/DC0%0/3
$token_type == 63 or $token_type == 75 and $token_data eq "BEGIN"
$token_type == 63
$token_type == 75
$token_data eq "BEGIN"
Truth table0%0/4
A or B and C
A= $token_type == 63B= $token_type == 75C= $token_data eq "BEGIN"
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | $token_type == FUNCTION_DECL || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | ($token_type == MOD_WORD && $token_data eq 'BEGIN') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # for function declare and BEGIN block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | for ($i++; $token = $tokens->[$i]; $i++) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $token_type = $token->{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ($token_type == LEFT_BRACE) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $i--; # rewind | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ($is_exited_by_depth{$depth} && !$is_in_ignore_context_by_depth{$depth}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$is_exited_by_depth{$depth} and not $is_in_ignore_context_by_depth{$depth}
MC/DC0%0/2
$is_exited_by_depth{$depth} and not $is_in_ignore_context_by_depth{$depth}
$is_exited_by_depth{$depth}
not $is_in_ignore_context_by_depth{$depth}
Truth table0%0/3
A and not(B)
A= $is_exited_by_depth{$depth}B= not $is_in_ignore_context_by_depth{$depth}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $unreachable_token_by_depth{$depth} //= $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$unreachable_token_by_depth{$depth} //= $token
MC/DC0%0/2
$unreachable_token_by_depth{$depth} //= $token
$unreachable_token_by_depth{$depth}
$token
Truth table0%0/3
A //= B
A= $unreachable_token_by_depth{$depth}B= $token
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # for depth of top, finally | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if (my $unreachable_token = $unreachable_token_by_depth{$depth}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | push @violations, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | filename => $file, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | line => $unreachable_token->{line}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | description => DESC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | explanation => EXPL, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | policy => __PACKAGE__, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return \@violations; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||