« 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
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return if ! is_function_call($elem); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my $first_arg = ( parse_arg_list($elem) )[0]; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | return if !$first_arg; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $token = $first_arg->[0]; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | return if !$token; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if ( $token->isa('PPI::Token::Word') && $token eq 'local' ) { # handle local *DH | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token->isa("PPI::Token::Word") and $token eq "local"
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"
| |||||||||||||||||||||||||||||
| 39 | 0 | $token = $first_arg->[1]; # the token that follows local in the first argument | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | return if !$token; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( $token->isa('PPI::Token::Cast') && $token eq q{\\} ) { # handle \*DH | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$token->isa("PPI::Token::Cast") and $token eq "\\"
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 "\\"
| |||||||||||||||||||||||||||||
| 43 | 0 | $token = $first_arg->[1]; # the token that follows \ in the first argument | |||||||||||||||||||||||||||
| 44 | 0 | ▶ | return if !$token; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if ( $token->isa('PPI::Token::Symbol') ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | return $self->violation($DESC, $EXPL, $elem) if $token =~ m/^[*]/xms; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | } elsif ( $token->isa('PPI::Token::Word') ) { | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return $self->violation($DESC, $EXPL, $elem) if $token !~ m/^(?:my|our)$/xms; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | return; #ok! | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 40 | 1; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||