Sort/Sub/naturally.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 90.7% 39 / 43 CC 4 SCAR 8.3
CC
4
Cov
97%
__ANON__
4.0
meta
2.0
BEGIN
1.0
CRAP 2.3
« Sort/Sub/by_perl_code.pm ↑ Summary Sort/Sub/by_rand.pm »
1 package Sort::Sub::naturally;
2  
3 3 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 3 our $DATE = '2024-07-17'; # DATE
9 3 our $DIST = 'Sort-Sub'; # DIST
10 3 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 naturally (by number or string parts)',
16 };
17 }
18  
19 5 ▶sub gen_sorter {
Subroutine gen_sorter: called CC=1 SCAR=0.0
Pod undocumented
20 5 require Sort::Naturally;
21  
22 5 my ($is_reverse, $is_ci) = @_;
23  
24 15 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
25 3 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 15 my $caller = caller();
28 15 ▶ my $a = @_ ? $_[0] : ${"$caller\::a"};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 6 9 15
29 15 ▶ my $b = @_ ? $_[1] : ${"$caller\::b"};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 6 9 15
30  
31 15 ▶ if ($is_reverse) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_reverse) { } 3 12 15
32 3 Sort::Naturally::ncmp($b, $a);
33 } else {
34 12 Sort::Naturally::ncmp($a, $b);
35 }
36 5 };
37 }
38  
39 3 1;
40 # ABSTRACT: Sort naturally (by number or string parts)
41  
42 __END__
« Sort/Sub/by_perl_code.pm ↑ Summary Sort/Sub/by_rand.pm »