« Perl/Lint/Policy/Subroutines/ProtectPrivateSubs.pm
↑ Summary
Perl/Lint/Policy/Variables/ProhibitPunctuationVars.pm »
| 1 | package Perl::Lint::Policy::InputOutput::ProhibitTwoArgOpen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 => 'Two-argument "open" used', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | EXPL => [207], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub evaluate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: not called CC=35 SCAR=71.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | my ($class, $file, $tokens, $src, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my @violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | for (my $i = 0; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if ($token_type == USE_DECL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Skip when `use (<=5.005)` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my $token_data = $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ($token_type == DOUBLE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $token_data =~ s/_//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($token_data <= 5.005) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | return []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ▶ | elsif ($token_type == BUILTIN_FUNC && $token_data eq 'open') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$token_type == 70 and $token_data eq "open"
MC/DC0%0/2
$token_type == 70 and $token_data eq "open"
$token_type == 70
$token_data eq "open"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "open"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my $token = $tokens->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $left_paren_num = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | for ($i++; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $token_kind = $token->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ($token_type == LEFT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | $left_paren_num++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | elsif ($token_type == RIGHT_PAREN) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | last if --$left_paren_num <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_kind != 3
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151
$token_type != 104 and $token_type != 146 and $token_type != 145
$token_type != 104 and $token_type != 146
MC/DC0%0/5
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_kind != 3
$token_type != 104
$token_type != 146
$token_type != 145
$token_type != 151
$token_kind != 3
Truth table0%0/6
A and B and C and D and E
A= $token_type != 104B= $token_type != 146C= $token_type != 145D= $token_type != 151E= $token_kind != 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | $token_type != COMMA && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $token_type != REG_DOUBLE_QUOTE && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $token_type != REG_QUOTE && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $token_type != REG_DELIM && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $token_kind != KIND_DECL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | push @args, $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (scalar @args < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $second = $args[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$second and $second eq "-|" || $second eq "|-" || $second =~ /STD(?:OUT|ERR|IN)\Z/
$second eq "-|" or $second eq "|-" or $second =~ /STD(?:OUT|ERR|IN)\Z/
$second eq "-|" or $second eq "|-"
MC/DC0%0/4
$second and $second eq "-|" || $second eq "|-" || $second =~ /STD(?:OUT|ERR|IN)\Z/
$second
$second eq "-|"
$second eq "|-"
$second =~ /STD(?:OUT|ERR|IN)\Z/
Truth table0%0/5
A and B or C or D
A= $secondB= $second eq "-|"C= $second eq "|-"D= $second =~ /STD(?:OUT|ERR|IN)\Z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | $second && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $second eq '-|' || $second eq '|-' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | $second =~ /STD(?:OUT|ERR|IN)\Z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | for (; my $token = $tokens->[$i]; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $token_type = $token->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $token_kind = $token->{kind}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ($token_kind == KIND_STMT_END || $token_kind == KIND_OP) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$token_kind == 21 or $token_kind == 1
MC/DC0%0/2
$token_kind == 21 or $token_kind == 1
$token_kind == 21
$token_kind == 1
Truth table0%0/3
A or B
A= $token_kind == 21B= $token_kind == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ▶ | elsif ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/12
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_kind != 3
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151
$token_type != 104 and $token_type != 146 and $token_type != 145
$token_type != 104 and $token_type != 146
MC/DC0%0/5
$token_type != 104 and $token_type != 146 and $token_type != 145 and $token_type != 151 and $token_kind != 3
$token_type != 104
$token_type != 146
$token_type != 145
$token_type != 151
$token_kind != 3
Truth table0%0/6
A and B and C and D and E
A= $token_type != 104B= $token_type != 146C= $token_type != 145D= $token_type != 151E= $token_kind != 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $token_type != COMMA && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | $token_type != REG_DOUBLE_QUOTE && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $token_type != REG_QUOTE && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | $token_type != REG_DELIM && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | $token_kind != KIND_DECL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | push @args, $token->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (scalar @args < 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | my $second = $args[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$second and $second eq "-|" || $second eq "|-" || $second =~ /STD(?:OUT|ERR|IN)\Z/
$second eq "-|" or $second eq "|-" or $second =~ /STD(?:OUT|ERR|IN)\Z/
$second eq "-|" or $second eq "|-"
MC/DC0%0/4
$second and $second eq "-|" || $second eq "|-" || $second =~ /STD(?:OUT|ERR|IN)\Z/
$second
$second eq "-|"
$second eq "|-"
$second =~ /STD(?:OUT|ERR|IN)\Z/
Truth table0%0/5
A and B or C or D
A= $secondB= $second eq "-|"C= $second eq "|-"D= $second =~ /STD(?:OUT|ERR|IN)\Z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $second && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $second eq '-|' || $second eq '|-' || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | $second =~ /STD(?:OUT|ERR|IN)\Z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | push @violations, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | filename => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | line => $token->{line}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | description => DESC, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | explanation => EXPL, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | policy => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return \@violations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||