| 1 | package Perl::Critic::Policy::Subroutines::ProhibitExplicitReturnUndef; | ||||||||||
| 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 }; | ||||||||
|
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{"return" statement with explicit "undef"}; | |||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => [ 199 ]; | |||||||||
| 17 | |||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||
| 19 | |||||||||||
| 20 | 90 | ▶ | sub supported_parameters { return () } | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | 75 | ▶ | 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=6 SCAR=18.2
Pod
documented
| |||||||||||
| 28 | 361 | my ( $self, $elem, undef ) = @_; | |||||||||
| 29 | 361 | ▶ | return if $elem->content() ne 'return'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 5 | ▶ | return if is_hash_key($elem); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | |||||||||||
| 32 | 5 | my $sib = $elem->snext_sibling(); | |||||||||
| 33 | 5 | ▶ | return if !$sib; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 5 | ▶ | return if !$sib->isa('PPI::Token::Word'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 1 | ▶ | return if $sib->content() ne 'undef'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | # Must be 'return undef' | ||||||||||
| 38 | 1 | return $self->violation( $DESC, $EXPL, $elem ); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 40 | 1; | |||||||||
| 42 | |||||||||||
| 43 | __END__ | ||||||||||