Perl/Lint/Policy/InputOutput/ProhibitExplicitStdin.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 42.0% 21 / 50 CC 7 SCAR 35.0
CC
7
Cov
39%
evaluate
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 33.1
« Perl/Lint/Policy/Modules/ProhibitAutomaticExportation.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm »
1 package Perl::Lint::Policy::InputOutput::ProhibitExplicitStdin;
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 => 'Use "<>" or "<ARGV>" or a prompting module instead of "<STDIN>"',
9 EXPL => [216, 220, 221],
10 2 };
11  
12 0 ▶sub evaluate {
Subroutine evaluate: not called CC=7 SCAR=40.3
Pod undocumented
13 0 my ($class, $file, $tokens, $src, $args) = @_;
14  
15 0 my @violations;
16 0 my $is_in_context_of_close = 0;
17 0 ▶ for (my $i = 0; my $token = $tokens->[$i]; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $tokens->[$i]) 0 0 0
18 0 my $token_type = $token->{type};
19 0 my $token_data = $token->{data};
20  
21 0 ▶ if ($token_type == TYPE_STDIN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token_type == 79) { } 0 0 0
elsif ($token_type == 70 and $token_data eq 'close') { } 0 0 0
elsif ($token_type == 106) { } 0 0 0
22 0 ▶ next if $is_in_context_of_close;
Branch: 1 branch
BranchTrueFalseTotal
if $is_in_context_of_close 0 0 0
23 push @violations, {
24 filename => $file,
25 line => $token->{line},
26 0 description => DESC,
27 explanation => EXPL,
28 policy => __PACKAGE__,
29 };
30 }
31 ▶ elsif ($token_type == BUILTIN_FUNC && $token_data eq 'close') {
Condition0%0/3
$token_type == 70 and $token_data eq "close"
!ll&&!rl&&r
000
MC/DC0%0/2
$token_type == 70 and $token_data eq "close"
$token_type == 70 $token_data eq "close"
Truth table0%0/3
A and B
A= $token_type == 70B= $token_data eq "close"
ABresult
0X0
100
111
32 0 $is_in_context_of_close = 1;
33 }
34 elsif ($token_type == SEMI_COLON) {
35 0 $is_in_context_of_close = 0;
36 }
37 }
38  
39 0 return \@violations;
40 }
41  
42 2 1;
43  
« Perl/Lint/Policy/Modules/ProhibitAutomaticExportation.pm ↑ Summary Perl/Lint/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm »