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

filter: Statementstmt 80.0% 32 / 40 Branchbran 10.0% 1 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 100% 12 / 12 Podpod 80.0% 4 / 5 totaltotal 60.4% 49 / 81 CC 9 SCAR 34.3
CC
9
Cov
56%
violates
67.4
BEGIN
1.0
BEGIN
1.0
CRAP 30.9
« lib/Perl/Critic/Policy/Documentation/PodSpelling.pm ↑ Summary lib/Perl/Critic/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm »
1 package Perl::Critic::Policy::InputOutput::ProhibitTwoArgOpen;
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  
7 40 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 40 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 40 ▶use Perl::Critic::Utils qw{ :severities :classification :ppi };
Subroutine BEGIN: called CC=1 SCAR=0.0
12 40 ▶use parent 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 40 our $VERSION = '1.156';
15  
16 #-----------------------------------------------------------------------------
17  
18 40 Readonly::Scalar my $FORK_HANDLES_RX => qr/\A (?: -[|] | [|]- ) \z/xms;
19 40 Readonly::Scalar my $DESC => q{Two-argument "open" used};
20 40 Readonly::Scalar my $EXPL => [ 207 ];
21  
22 40 Readonly::Scalar my $MINIMUM_VERSION => version->new(5.006);
23  
24 #-----------------------------------------------------------------------------
25  
26 90 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
27 74 ▶sub default_severity { return $SEVERITY_HIGHEST }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
28 91 ▶sub default_themes { return qw(core pbp bugs security certrule) }
Subroutine default_themes: called CC=1 SCAR=0.0
Pod documented
29 37 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
30  
31 #-----------------------------------------------------------------------------
32  
33 361 ▶sub violates {
Subroutine violates: called CC=9 SCAR=42.1
Pod documented
34 361 my ($self, $elem, $document) = @_;
35  
36 361 ▶ return if $elem->content() ne 'open';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "open" 361 0 361
37 0 ▶ return if ! is_function_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
unless is_function_call($elem) 0 0 0
38  
39 0 my $version = $document->highest_explicit_perl_version();
40 0 ▶ return if $version and $version < $MINIMUM_VERSION;
Branch: 1 branch
BranchTrueFalseTotal
if $version and $version < $MINIMUM_VERSION 0 0 0
Condition0%0/3
$version and $version < $MINIMUM_VERSION
!ll&&!rl&&r
000
MC/DC0%0/2
$version and $version < $MINIMUM_VERSION
$version $version < $MINIMUM_VERSION
Truth table0%0/3
A and B
A= $versionB= $version < $MINIMUM_VERSION
ABresult
0X0
100
111
41  
42 0 my @args = parse_arg_list($elem);
43  
44 0 ▶ if ( scalar @args <= 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args <= 2) 0 0 0
45 0 ▶ return if @args == 2
Branch: 1 branch
BranchTrueFalseTotal
if @args == 2 and $args[1][0]->isa("PPI::Token::Quote") and $args[1][0]->string =~ /$FORK_HANDLES_RX/ 0 0 0
Condition0%0/6
@args == 2 and $args[1][0]->isa("PPI::Token::Quote") and $args[1][0]->string =~ /$FORK_HANDLES_RX/
!ll&&!rl&&r
000
@args == 2 and $args[1][0]->isa("PPI::Token::Quote")
!ll&&!rl&&r
000
MC/DC0%0/3
@args == 2 and $args[1][0]->isa("PPI::Token::Quote") and $args[1][0]->string =~ /$FORK_HANDLES_RX/
@args == 2 $args[1][0]->isa("PPI::Token::Quote") $args[1][0]->string =~ /$FORK_HANDLES_RX/
Truth table0%0/4
A and B and C
A= @args == 2B= $args[1][0]->isa("PPI::Token::Quote")C= $args[1][0]->string =~ /$FORK_HANDLES_RX/
ABCresult
0XX0
10X0
1100
1111
46 && $args[1]->[0]->isa( 'PPI::Token::Quote' )
47 && $args[1]->[0]->string() =~ $FORK_HANDLES_RX;
48 0 return $self->violation( $DESC, $EXPL, $elem );
49 }
50  
51 0 return; # ok!
52 }
53  
54 40 1;
55  
56 __END__
« lib/Perl/Critic/Policy/Documentation/PodSpelling.pm ↑ Summary lib/Perl/Critic/Policy/RegularExpressions/ProhibitEscapedMetacharacters.pm »