Sort/Sub/by_length.pm

filter: Statementstmt 88.4% 23 / 26 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 80.4% 33 / 41 CC 4 SCAR 8.8
CC
4
Cov
84%
__ANON__
4.2
meta
2.0
gen_sorter
1.0
CRAP 2.4
« Sort/Sub/by_perl_op.pm ↑ Summary Sort/Sub/numerically.pm »
1 package Sort::Sub::by_length;
2  
3 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 2 our $DATE = '2024-07-17'; # DATE
9 2 our $DIST = 'Sort-Sub'; # DIST
10 2 our $VERSION = '0.121'; # VERSION
11  
12 0 ▶sub meta {
Subroutine meta: not called CC=1 SCAR=6.9
Pod undocumented
13 return {
14 0 v => 1,
15 summary => 'Sort by length of string',
16 };
17 }
18 3 ▶sub gen_sorter {
Subroutine gen_sorter: called CC=1 SCAR=0.1
Pod undocumented
19 3 my ($is_reverse, $is_ci) = @_;
20  
21 8 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=14.5
22 2 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 8 my $caller = caller();
25 0 ▶ my $a = @_ ? $_[0] : ${"$caller\::a"};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 8 0 8
26 0 ▶ my $b = @_ ? $_[1] : ${"$caller\::b"};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 8 0 8
27  
28 8 my $cmp = length($a) <=> length($b);
29 8 ▶ $is_reverse ? -1*$cmp : $cmp;
Branch: 1 branch
BranchTrueFalseTotal
$is_reverse ? : 2 6 8
30 3 };
31 }
32  
33 2 1;
34 # ABSTRACT: Sort by length of string
35  
36 __END__
« Sort/Sub/by_perl_op.pm ↑ Summary Sort/Sub/numerically.pm »