« Perl/Lint/Policy/Variables/ProhibitMatchVars.pm
↑ Summary
Perl/Lint/Policy/TestingAndDebugging/ProhibitNoWarnings.pm »
| 1 | package Perl::Lint::Policy::InputOutput::ProhibitBacktickOperators; | ||||||||||||||||||||||||||||||||||||||||||
| 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 Perl::Lint::Constants::Kind; | ||||||||||||||||||||||||||||||||||||||||
|
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 => 'Backtick operator used', | |||||||||||||||||||||||||||||||||||||||||
| 10 | EXPL => 'Use IPC::Open3 instead', | ||||||||||||||||||||||||||||||||||||||||||
| 11 | VOID_DESC => 'Backtick operator used in void context', | ||||||||||||||||||||||||||||||||||||||||||
| 12 | VOID_EXPL => 'Assign result to a variable or use system() instead', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $only_in_void_context = $args->{prohibit_backtick_operators}->{only_in_void_context}; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||||||||
| 21 | my $is_in_assign_context; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $is_in_call_context; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $is_in_ctrl_context; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $token_kind = $token->{kind}; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($token_type == BUILTIN_FUNC || $token_type == KEY) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 70 or $token_type == 122
MC/DC0%0/2
$token_type == 70 or $token_type == 122
$token_type == 70
$token_type == 122
Truth table0%0/3
A or B
A= $token_type == 70B= $token_type == 122
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | $is_in_call_context = 1; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ($token_kind == KIND_STMT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $is_in_ctrl_context = 1; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ($only_in_void_context && ($is_in_call_context || $is_in_ctrl_context)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$only_in_void_context and $is_in_call_context || $is_in_ctrl_context
$is_in_call_context or $is_in_ctrl_context
MC/DC0%0/3
$only_in_void_context and $is_in_call_context || $is_in_ctrl_context
$only_in_void_context
$is_in_call_context
$is_in_ctrl_context
Truth table0%0/4
A and B or C
A= $only_in_void_contextB= $is_in_call_contextC= $is_in_ctrl_context
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $left_paren_num = 1; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | last if --$left_paren_num <= 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $is_in_call_context = 0; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $is_in_ctrl_context = 0; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ($token_type == ASSIGN) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $is_in_assign_context = 1; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($token_type == SEMI_COLON) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $is_in_assign_context = 0; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($token_type == EXEC_STRING || $token_type == REG_EXEC) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token_type == 174 or $token_type == 148
MC/DC0%0/2
$token_type == 174 or $token_type == 148
$token_type == 174
$token_type == 148
Truth table0%0/3
A or B
A= $token_type == 174B= $token_type == 148
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | next if ($only_in_void_context && $is_in_assign_context); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$only_in_void_context and $is_in_assign_context
MC/DC0%0/2
$only_in_void_context and $is_in_assign_context
$only_in_void_context
$is_in_assign_context
Truth table0%0/3
A and B
A= $only_in_void_contextB= $is_in_assign_context
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $desc = VOID_DESC; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $expl = VOID_EXPL; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ($is_in_assign_context) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $desc = DESC; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $expl = EXPL; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | description => $desc, | |||||||||||||||||||||||||||||||||||||||||
| 80 | explanation => $expl, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||