lib/Perl/Critic/Policy/InputOutput/ProhibitBarewordDirHandles.pm

filter: Statementstmt 64.2% 27 / 42 Branchbran 4.1% 1 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 46.7% 43 / 92 CC 15 SCAR 47.9
CC
15
Cov
39%
violates
199.6
BEGIN
1.0
BEGIN
1.0
CRAP 120.2
« lib/Perl/Critic/Policy/InputOutput/RequireBriefOpen.pm ↑ Summary lib/Perl/Critic/Policy/RegularExpressions/ProhibitSingleCharAlternation.pm »
1 package Perl::Critic::Policy::InputOutput::ProhibitBarewordDirHandles;
2  
3 40 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 ▶use Perl::Critic::Utils qw{ :severities :classification :ppi };
Subroutine BEGIN: called CC=1 SCAR=0.0
9 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 40 our $VERSION = '1.156';
12  
13 #-----------------------------------------------------------------------------
14  
15 40 Readonly::Scalar my $DESC => q{Bareword dir handle opened};
16 40 Readonly::Scalar my $EXPL => [ 202, 204 ];
17  
18 #-----------------------------------------------------------------------------
19  
20 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 74 ▶sub default_severity { return $SEVERITY_HIGHEST }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
22 91 ▶sub default_themes { return qw( core pbp bugs certrec ) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
23 37 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
24  
25 #-----------------------------------------------------------------------------
26  
27 361 ▶sub violates {
Subroutine violates: called CC=15 SCAR=53.0
Pod documented
28 361 my ($self, $elem, undef) = @_;
29  
30 361 ▶ return if $elem->content() ne 'opendir';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "opendir" 361 0 361
31 0 ▶ return if ! is_function_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 0 0 0
32  
33 0 my $first_arg = ( parse_arg_list($elem) )[0];
34 0 ▶ return if !$first_arg;
Branch: 1 branch
BranchTrueFalseTotal
unless $first_arg 0 0 0
35 0 my $token = $first_arg->[0];
36 0 ▶ return if !$token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
37  
38 0 ▶ if ( $token->isa('PPI::Token::Word') && $token eq 'local' ) { # handle local *DH
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isa("PPI::Token::Word") and $token eq "local") 0 0 0
Condition0%0/3
$token->isa("PPI::Token::Word") and $token eq "local"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->isa("PPI::Token::Word") and $token eq "local"
$token->isa("PPI::Token::Word") $token eq "local"
Truth table0%0/3
A and B
A= $token->isa("PPI::Token::Word")B= $token eq "local"
ABresult
0X0
100
111
39 0 $token = $first_arg->[1]; # the token that follows local in the first argument
40 0 ▶ return if !$token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
41 }
42 0 ▶ if ( $token->isa('PPI::Token::Cast') && $token eq q{\\} ) { # handle \*DH
Branch: 1 branch
BranchTrueFalseTotal
if ($token->isa("PPI::Token::Cast") and $token eq "\\") 0 0 0
Condition0%0/3
$token->isa("PPI::Token::Cast") and $token eq "\\"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->isa("PPI::Token::Cast") and $token eq "\\"
$token->isa("PPI::Token::Cast") $token eq "\\"
Truth table0%0/3
A and B
A= $token->isa("PPI::Token::Cast")B= $token eq "\\"
ABresult
0X0
100
111
43 0 $token = $first_arg->[1]; # the token that follows \ in the first argument
44 0 ▶ return if !$token;
Branch: 1 branch
BranchTrueFalseTotal
unless $token 0 0 0
45 }
46  
47 0 ▶ if ( $token->isa('PPI::Token::Symbol') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->isa('PPI::Token::Symbol')) { } 0 0 0
elsif ($token->isa('PPI::Token::Word')) { } 0 0 0
48 0 ▶ return $self->violation($DESC, $EXPL, $elem) if $token =~ m/^[*]/xms;
Branch: 1 branch
BranchTrueFalseTotal
if $token =~ /^[*]/msx 0 0 0
49 } elsif ( $token->isa('PPI::Token::Word') ) {
50 0 ▶ return $self->violation($DESC, $EXPL, $elem) if $token !~ m/^(?:my|our)$/xms;
Branch: 1 branch
BranchTrueFalseTotal
unless $token =~ /^(?:my|our)$/msx 0 0 0
51 }
52  
53 0 return; #ok!
54 }
55  
56 40 1;
57  
58 __END__
« lib/Perl/Critic/Policy/InputOutput/RequireBriefOpen.pm ↑ Summary lib/Perl/Critic/Policy/RegularExpressions/ProhibitSingleCharAlternation.pm »