| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | return if is_method_call($elem); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | return if is_hash_key($elem); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | return if is_subroutine_name($elem); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | my $suspectproto = $elem->snext_sibling(); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | if ( $suspectproto && $suspectproto->isa( 'PPI::Token::Symbol' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$suspectproto and $suspectproto->isa("PPI::Token::Symbol")
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")
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%2/6
$suspectproto->snext_sibling and $suspectproto->snext_sibling->isa("PPI::Token::Operator") and $suspectproto->snext_sibling eq "||"
$suspectproto->snext_sibling and $suspectproto->snext_sibling->isa("PPI::Token::Operator")
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 "||"
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||