blib/lib/Perl/Lint/Policy/InputOutput/ProhibitBarewordFileHandles.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 SCAR 0.1
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Perl/Lint/Policy/InputOutput/ProhibitBacktickOperators.pm ↑ Summary blib/lib/Perl/Lint/Policy/InputOutput/ProhibitExplicitStdin.pm »
1 package Perl::Lint::Policy::InputOutput::ProhibitBarewordFileHandles;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Perl::Lint::Constants::Type;
Subroutine BEGIN: called CC=1 SCAR=2.6
5 use Perl::Lint::Constants::Kind;
6 use parent "Perl::Lint::Policy";
7  
8 use constant {
9 DESC => 'Bareword file handle opened',
10 EXPL => [202, 204],
11 };
12  
13 sub evaluate {
14 my ($class, $file, $tokens, $src, $args) = @_;
15  
16 my @violations;
17 for (my $i = 0; my $token = $tokens->[$i]; $i++) {
18 my $token_type = $token->{type};
19 my $token_data = $token->{data};
20  
21 if ($token_type == BUILTIN_FUNC && $token_data eq 'open') {
22 $token = $tokens->[++$i];
23 $token_type = $token->{type};
24  
25 if ($token_type == LEFT_PAREN) {
26 $token = $tokens->[++$i];
27 $token_type = $token->{type};
28 }
29  
30 if ($token_type == KEY) {
31 push @violations, {
32 filename => $file,
33 line => $token->{line},
34 description => DESC,
35 explanation => EXPL,
36 policy => __PACKAGE__,
37 };
38 }
39 }
40 }
41  
42 return \@violations;
43 }
44  
45 1;
46  
« blib/lib/Perl/Lint/Policy/InputOutput/ProhibitBacktickOperators.pm ↑ Summary blib/lib/Perl/Lint/Policy/InputOutput/ProhibitExplicitStdin.pm »