Policy/Bangs/ProhibitRefProtoOrProto.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 64.2% 9 / 14 Conditioncond 33.3% 3 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 88.8% 8 / 9 Podpod 80.0% 4 / 5 totaltotal 74.3% 55 / 74 CC 11 SCAR 21.6
CC
11
Cov
78%
violates
14.2
default_themes
2.0
BEGIN
1.0
CRAP 8.7
↑ Summary Policy/Bangs/ProhibitNumberedNames.pm »
1 package Perl::Critic::Policy::Bangs::ProhibitRefProtoOrProto;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Perl::Critic::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use base 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 our $VERSION = '1.14';
9  
10 5 ▶sub supported_parameters { return () }
Subroutine supported_parameters: called CC=1 SCAR=0.0
Pod undocumented
11 1 ▶sub default_severity { return $SEVERITY_HIGH }
Subroutine default_severity: called CC=1 SCAR=0.0
Pod documented
12 0 ▶sub default_themes { return qw( bangs complexity ) }
Subroutine default_themes: not called CC=1 SCAR=6.9
Pod documented
13 2 ▶sub applies_to { return 'PPI::Token::Word' }
Subroutine applies_to: called CC=1 SCAR=0.0
Pod documented
14  
15  
16 4 ▶sub violates {
Subroutine violates: called CC=11 SCAR=26.5
Pod documented
17 4 my ( $self, $elem, $doc ) = @_;
18  
19 4 ▶ return if $elem ne 'ref';
Branch: 1 branch
BranchTrueFalseTotal
if $elem ne "ref" 2 2 4
20 2 ▶ return if is_method_call($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_method_call($elem) 0 2 2
21 2 ▶ return if is_hash_key($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_hash_key($elem) 0 2 2
22 2 ▶ return if is_subroutine_name($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_subroutine_name($elem) 0 2 2
23  
24 2 my $suspectproto = $elem->snext_sibling();
25 2 ▶ if ( $suspectproto && $suspectproto->isa( 'PPI::Token::Symbol' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($suspectproto and $suspectproto->isa("PPI::Token::Symbol")) 2 0 2
Condition33%1/3
$suspectproto and $suspectproto->isa("PPI::Token::Symbol")
!ll&&!rl&&r
002
MC/DC0%0/2
$suspectproto and $suspectproto->isa("PPI::Token::Symbol")
$suspectproto $suspectproto->isa("PPI::Token::Symbol")
Truth table33%1/3
A and B
A= $suspectprotoB= $suspectproto->isa("PPI::Token::Symbol")
ABresult
0X0
100
111
26 # $suspectproto is the thing I'm calling ref on. Let's see if there's a || after that.
27 2 ▶ if ( $suspectproto->snext_sibling()
Branch: 1 branch
BranchTrueFalseTotal
if ($suspectproto->snext_sibling and $suspectproto->snext_sibling->isa("PPI::Token::Operator") and $suspectproto->snext_sibling eq "||") 2 0 2
Condition33%2/6
$suspectproto->snext_sibling and $suspectproto->snext_sibling->isa("PPI::Token::Operator") and $suspectproto->snext_sibling eq "||"
!ll&&!rl&&r
002
$suspectproto->snext_sibling and $suspectproto->snext_sibling->isa("PPI::Token::Operator")
!ll&&!rl&&r
002
MC/DC0%0/3
$suspectproto->snext_sibling and $suspectproto->snext_sibling->isa("PPI::Token::Operator") and $suspectproto->snext_sibling eq "||"
$suspectproto->snext_sibling $suspectproto->snext_sibling->isa("PPI::Token::Operator") $suspectproto->snext_sibling eq "||"
Truth table25%1/4
A and B and C
A= $suspectproto->snext_siblingB= $suspectproto->snext_sibling->isa("PPI::Token::Operator")C= $suspectproto->snext_sibling eq "||"
ABCresult
0XX0
10X0
1100
1111
28 && $suspectproto->snext_sibling->isa( 'PPI::Token::Operator' )
29 && $suspectproto->snext_sibling() eq q{||} ) {
30 2 my $or = $suspectproto->snext_sibling;
31 # this is where I test to see if the thing after the || is the same as the thing before the ref
32 2 ▶ if ( $or->snext_sibling() eq $suspectproto->content() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($or->snext_sibling eq $suspectproto->content) 1 1 2
33 # here it looks like we have ref $proto || $proto
34 1 my $desc = q{"ref $proto || $proto" construct found}; ## no critic (RequireInterpolationOfMetachars)
35 1 my $expl = q{Probably cut-and-pasted example code};
36 1 return $self->violation( $desc, $expl, $elem );
37 }
38 }
39 }
40  
41 1 return;
42 }
43  
44 5 1;
45  
46 __END__
↑ Summary Policy/Bangs/ProhibitNumberedNames.pm »