« Perl/Lint/Policy/ValuesAndExpressions/ProhibitCommaSeparatedStatements.pm
↑ Summary
Perl/Lint/Policy/RegularExpressions/RequireExtendedFormatting.pm »
| 1 | package Perl::Lint::Policy::InputOutput::RequireCheckedSyscalls; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 List::Util qw/any/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Perl::Lint::Constants::Type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Perl::Lint::Constants::Kind; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use B::Keywords; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use parent "Perl::Lint::Policy"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | DESC => 'Return value of flagged function ignored', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | EXPL => [208, 278], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=78 SCAR=77.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | my $is_target_all = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | my @target_functions = qw/open close say/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | my $allowed_functions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | if (my $required_checked_syscalls_arg = $args->{require_checked_syscalls}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if (my $functions = $required_checked_syscalls_arg->{functions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if ($functions eq ':builtins') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | @target_functions = @B::Keywords::Functions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | elsif ($functions eq ':all') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $is_target_all = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | @target_functions = ($functions); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if ($allowed_functions = $required_checked_syscalls_arg->{exclude_functions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | @target_functions = grep {$_ ne $allowed_functions} @target_functions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my $is_in_assign_context = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | my $is_in_statement_context = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | my $is_called_syscalls_in_void = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | my $is_enabled_autodie = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | my @violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 49 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 49 | my $token_kind = $token->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 49 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 49 | ▶ | if ($token_type == ASSIGN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $is_in_assign_context = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 48 | ▶ | if ($token_type == USED_NAME) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 8 | ▶ | if ($token_data eq 'Fatal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $next_token = $tokens->[$i+1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $next_token_type = $next_token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $next_token_data = $next_token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | if ($next_token_type == REG_LIST) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | for ($i += 3; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | if ($token_type == REG_EXP) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | @target_functions = grep {$_ ne $token_data} @target_functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | elsif ($token_type == REG_DELIM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | elsif ($next_token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $left_paren_num = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | for ($i += 2; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | elsif (($token_type == STRING || $token_type == RAW_STRING) && any {$_ eq $token_data} @target_functions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/6
$token_type == 172 || $token_type == 173 and &any(sub {
$_ eq $token_data;
}
, @target_functions)
$token_type == 172 or $token_type == 173
MC/DC0%0/3
$token_type == 172 || $token_type == 173 and &any(sub {
$_ eq $token_data;
}
, @target_functions)
$token_type == 172
$token_type == 173
&any(sub {
$_ eq $token_data;
}
, @target_functions)
Truth table0%0/5
A or B and C
A= $token_type == 172B= $token_type == 173C= &any(sub {
$_ eq $token_data;
}
, @target_functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | elsif (($next_token_type == STRING || $next_token_type == RAW_STRING) && any {$_ eq $next_token_data} @target_functions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/6
$next_token_type == 172 || $next_token_type == 173 and &any(sub {
$_ eq $next_token_data;
}
, @target_functions)
$next_token_type == 172 or $next_token_type == 173
MC/DC0%0/3
$next_token_type == 172 || $next_token_type == 173 and &any(sub {
$_ eq $next_token_data;
}
, @target_functions)
$next_token_type == 172
$next_token_type == 173
&any(sub {
$_ eq $next_token_data;
}
, @target_functions)
Truth table0%0/5
A or B and C
A= $next_token_type == 172B= $next_token_type == 173C= &any(sub {
$_ eq $next_token_data;
}
, @target_functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | elsif ($token_data eq 'autodie') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($tokens->[$i+1]->{type} == REG_LIST) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | for ($i += 3; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($token_type == REG_EXP && $token->{data} =~ /\A\s*:io\s*\Z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$token_type == 187 and $token->{"data"} =~ /\A\s*:io\s*\Z/
MC/DC0%0/2
$token_type == 187 and $token->{"data"} =~ /\A\s*:io\s*\Z/
$token_type == 187
$token->{"data"} =~ /\A\s*:io\s*\Z/
Truth table0%0/3
A and B
A= $token_type == 187B= $token->{"data"} =~ /\A\s*:io\s*\Z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $is_enabled_autodie = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | elsif ($token_type == REG_DELIM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $is_enabled_autodie = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 40 | ▶ | if ($token_type == NAMESPACE && $token_data eq 'Fatal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$token_type == 127 and $token_data eq "Fatal"
MC/DC0%0/2
$token_type == 127 and $token_data eq "Fatal"
$token_type == 127
$token_data eq "Fatal"
Truth table33%1/3
A and B
A= $token_type == 127B= $token_data eq "Fatal"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $skipped_token = $tokens->[$i+2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ($skipped_token && $skipped_token->{type} == NAMESPACE && $skipped_token->{data} eq 'Exception') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$skipped_token and $skipped_token->{"type"} == 127 and $skipped_token->{"data"} eq "Exception"
$skipped_token and $skipped_token->{"type"} == 127
MC/DC0%0/3
$skipped_token and $skipped_token->{"type"} == 127 and $skipped_token->{"data"} eq "Exception"
$skipped_token
$skipped_token->{"type"} == 127
$skipped_token->{"data"} eq "Exception"
Truth table0%0/4
A and B and C
A= $skipped_tokenB= $skipped_token->{"type"} == 127C= $skipped_token->{"data"} eq "Exception"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | for ($i += 3; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if ($token_type == REG_LIST) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | for ($i += 2; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ($token_type == REG_EXP) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | @target_functions = grep {$_ ne $token_data} @target_functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | elsif ($token_type == REG_DELIM) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | elsif ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $left_paren_num = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | elsif (($token_type == STRING || $token_type == RAW_STRING) && any {$_ eq $token_data} @target_functions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/6
$token_type == 172 || $token_type == 173 and &any(sub {
$_ eq $token_data;
}
, @target_functions)
$token_type == 172 or $token_type == 173
MC/DC0%0/3
$token_type == 172 || $token_type == 173 and &any(sub {
$_ eq $token_data;
}
, @target_functions)
$token_type == 172
$token_type == 173
&any(sub {
$_ eq $token_data;
}
, @target_functions)
Truth table0%0/5
A or B and C
A= $token_type == 172B= $token_type == 173C= &any(sub {
$_ eq $token_data;
}
, @target_functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | elsif (($token_type == STRING || $token_type == RAW_STRING) && any {$_ eq $token_data} @target_functions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Condition0%0/6
$token_type == 172 || $token_type == 173 and &any(sub {
$_ eq $token_data;
}
, @target_functions)
$token_type == 172 or $token_type == 173
MC/DC0%0/3
$token_type == 172 || $token_type == 173 and &any(sub {
$_ eq $token_data;
}
, @target_functions)
$token_type == 172
$token_type == 173
&any(sub {
$_ eq $token_data;
}
, @target_functions)
Truth table0%0/5
A or B and C
A= $token_type == 172B= $token_type == 173C= &any(sub {
$_ eq $token_data;
}
, @target_functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | elsif ($token->{kind} == KIND_STMT_END) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 40 | ▶ | if ($token_kind == KIND_STMT) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | $is_in_statement_context = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ▶ | if ($tokens->[$i+1]->{type} == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | my $left_paren_num = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 1 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 39 | ▶ | if ($token_type == BUILTIN_FUNC || ($is_target_all && $token_type == RETURN)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$token_type == 70 or $is_target_all and $token_type == 0
$is_target_all and $token_type == 0
MC/DC33%1/3
$token_type == 70 or $is_target_all and $token_type == 0
$token_type == 70
$is_target_all
$token_type == 0
Truth table50%2/4
A or B and C
A= $token_type == 70B= $is_target_allC= $token_type == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | if ($is_target_all || any {$_ eq $token_data} @target_functions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.8
Branch: 2 branches
Condition33%1/3
$is_target_all or &any(sub {
$_ eq $token_data;
}
, @target_functions)
MC/DC0%0/2
$is_target_all or &any(sub {
$_ eq $token_data;
}
, @target_functions)
$is_target_all
&any(sub {
$_ eq $token_data;
}
, @target_functions)
Truth table33%1/3
A or B
A= $is_target_allB= &any(sub {
$_ eq $token_data;
}
, @target_functions)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if (!$is_in_assign_context && !$is_in_statement_context) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$is_in_assign_context or $is_in_statement_context
MC/DC0%0/2
$is_in_assign_context or $is_in_statement_context
$is_in_assign_context
$is_in_statement_context
Truth table0%0/3
A or B
A= $is_in_assign_contextB= $is_in_statement_context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $is_called_syscalls_in_void = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | elsif ($token_data eq 'no') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $next_token = $tokens->[++$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($next_token->{type} == KEY && $next_token->{data} eq 'autodie') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$next_token->{"type"} == 122 and $next_token->{"data"} eq "autodie"
MC/DC0%0/2
$next_token->{"type"} == 122 and $next_token->{"data"} eq "autodie"
$next_token->{"type"} == 122
$next_token->{"data"} eq "autodie"
Truth table0%0/3
A and B
A= $next_token->{"type"} == 122B= $next_token->{"data"} eq "autodie"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $is_enabled_autodie = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 38 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition11%1/9
$is_target_all and $token_type == 204 || $token_type == 122 && $$tokens[++$i]{"type"} == 107
$token_type == 204 or $token_type == 122 and $$tokens[++$i]{"type"} == 107
$token_type == 122 and $$tokens[++$i]{"type"} == 107
MC/DC0%0/4
$is_target_all and $token_type == 204 || $token_type == 122 && $$tokens[++$i]{"type"} == 107
$is_target_all
$token_type == 204
$token_type == 122
$$tokens[++$i]{"type"} == 107
Truth table20%1/5
A and B or C and D
A= $is_target_allB= $token_type == 204C= $token_type == 122D= $$tokens[++$i]{"type"} == 107
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | $is_target_all && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | ($token_type == CALL || ($token_type == KEY && $tokens->[++$i]->{type} == LEFT_PAREN)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ($allowed_functions && $token_data =~ /\A$allowed_functions\s*\(?/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$allowed_functions and $token_data =~ /\A$allowed_functions\s*\(?/
MC/DC0%0/2
$allowed_functions and $token_data =~ /\A$allowed_functions\s*\(?/
$allowed_functions
$token_data =~ /\A$allowed_functions\s*\(?/
Truth table0%0/3
A and B
A= $allowed_functionsB= $token_data =~ /\A$allowed_functions\s*\(?/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ▶ | elsif (!$is_in_assign_context && !$is_in_statement_context) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$is_in_assign_context || $is_in_statement_context
MC/DC0%0/2
$is_in_assign_context || $is_in_statement_context
$is_in_assign_context
$is_in_statement_context
Truth table0%0/3
A || B
A= $is_in_assign_contextB= $is_in_statement_context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $is_called_syscalls_in_void = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 38 | ▶ | if ($token_kind == KIND_OP) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | $is_in_statement_context = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | $is_called_syscalls_in_void = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 36 | ▶ | if ($token_kind == KIND_STMT_END) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 11 | ▶ | next if $is_enabled_autodie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 11 | ▶ | if ($is_called_syscalls_in_void) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 11 | $is_in_assign_context = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 11 | $is_in_statement_context = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 11 | $is_called_syscalls_in_void = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 11 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||