lib/Perl/Critic/Policy/Subroutines/ProhibitReturnSort.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 70.0% 7 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 80.0% 4 / 5 totaltotal 91.5% 54 / 59 CC 6 SCAR 11.1
CC
6
Cov
91%
violates
6.4
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
« lib/Perl/Critic/Violation.pm ↑ Summary lib/Perl/Critic/PolicyConfig.pm »
1 package Perl::Critic::Policy::Subroutines::ProhibitReturnSort;
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 followed by "sort"};
16 40 Readonly::Scalar my $EXPL => q{Behavior is undefined if called in scalar context};
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 73 ▶sub default_themes { return qw(core bugs certrule ) }
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.6
Pod documented
28 361 my ( $self, $elem, undef ) = @_;
29 361 ▶ return if $elem->content() ne 'return';
Branch: 1 branch
BranchTrueFalseTotal
if $elem->content ne "return" 356 5 361
30 5 ▶ return if is_hash_key($elem);
Branch: 1 branch
BranchTrueFalseTotal
if is_hash_key($elem) 0 5 5
31  
32 5 my $sib = $elem->snext_sibling();
33 5 ▶ return if !$sib;
Branch: 1 branch
BranchTrueFalseTotal
unless $sib 0 5 5
34 5 ▶ return if !$sib->isa('PPI::Token::Word');
Branch: 1 branch
BranchTrueFalseTotal
unless $sib->isa("PPI::Token::Word") 4 1 5
35 1 ▶ return if $sib->content() ne 'sort';
Branch: 1 branch
BranchTrueFalseTotal
if $sib->content ne "sort" 1 0 1
36  
37 # Must be 'return sort'
38 0 return $self->violation( $DESC, $EXPL, $elem );
39 }
40  
41 40 1;
42  
43 __END__
« lib/Perl/Critic/Violation.pm ↑ Summary lib/Perl/Critic/PolicyConfig.pm »