blib/lib/Sort/Sub/by_several.pm

filter: Statementstmt 76.0% 35 / 46 Branchbran 40.6% 13 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 62.0% 54 / 87 CC 17 SCAR 29.8
CC
17
Cov
62%
__ANON__
32.5
gen_sorter
9.3
meta
2.0
CRAP 19.6
↑ Summary
1 package Sort::Sub::by_several;
2  
3 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4 2 our $DATE = '2019-12-17'; # DATE
5 2 our $DIST = 'Sort-Sub-by_several'; # DIST
6 2 our $VERSION = '0.001'; # VERSION
7  
8 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 one or more sorters',
16 args => {
17 first => {schema=>'sortsub::spec*', req=>1, pos=>0},
18 second => {schema=>'sortsub::spec*', req=>0, pos=>1},
19 third => {schema=>'sortsub::spec*', req=>0, pos=>2},
20 fourth => {schema=>'sortsub::spec*', req=>0, pos=>3},
21 fifth => {schema=>'sortsub::spec*', req=>0, pos=>4},
22 },
23 args_rels => {
24 'dep_any&' => [
25 [second => ['first']],
26 [third => ['second']],
27 [fourth => ['third']],
28 [fifth => ['fourth']],
29 ],
30 },
31 };
32 }
33  
34 4 ▶sub gen_sorter {
Subroutine gen_sorter: called CC=6 SCAR=22.4
Pod undocumented
35 4 require Sort::Sub;
36 4 my ($is_reverse, $is_ci, $args) = @_;
37  
38 4 ▶ my $sorter1 = defined $args->{first} ? Sort::Sub::get_sorter($args->{first} ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'first'} ? : 4 0 4
39 4 ▶ my $sorter2 = defined $args->{second} ? Sort::Sub::get_sorter($args->{second}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'second'} ? : 4 0 4
40 4 ▶ my $sorter3 = defined $args->{third} ? Sort::Sub::get_sorter($args->{third} ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'third'} ? : 0 4 4
41 4 ▶ my $sorter4 = defined $args->{fourth} ? Sort::Sub::get_sorter($args->{fourth}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'fourth'} ? : 0 4 4
42 4 ▶ my $sorter5 = defined $args->{fifth} ? Sort::Sub::get_sorter($args->{fifth} ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $args->{'fifth'} ? : 0 4 4
43  
44 92 ▶ sub {
Subroutine __ANON__: called CC=12 SCAR=34.8
45 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
46  
47 92 my $caller = caller();
48 0 ▶ my $a = @_ ? $_[0] : ${"$caller\::a"};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 92 0 92
49 0 ▶ my $b = @_ ? $_[1] : ${"$caller\::b"};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 92 0 92
50  
51 92 my $cmp;
52  
53 {
54 92 ▶ $cmp = $sorter1->($a, $b); last if $cmp; last unless $sorter2;
Branch: 2 branches
BranchTrueFalseTotal
if $cmp 46 46 92
unless $sorter2 0 46 46
55 0 ▶ $cmp = $sorter2->($a, $b); last if $cmp; last unless $sorter3;
Branch: 2 branches
BranchTrueFalseTotal
if $cmp 46 0 46
unless $sorter3 0 0 0
56 0 ▶ $cmp = $sorter3->($a, $b); last if $cmp; last unless $sorter4;
Branch: 2 branches
BranchTrueFalseTotal
if $cmp 0 0 0
unless $sorter4 0 0 0
57 0 ▶ $cmp = $sorter4->($a, $b); last if $cmp; last unless $sorter5;
Branch: 2 branches
BranchTrueFalseTotal
if $cmp 0 0 0
unless $sorter5 0 0 0
58 0 $cmp = $sorter5->($a, $b);
59 }
60  
61 92 ▶ $is_reverse ? -1*$cmp : $cmp;
Branch: 1 branch
BranchTrueFalseTotal
$is_reverse ? : 49 43 92
62 4 };
63 }
64  
65 2 1;
66 # ABSTRACT: Sort by one or more sorters
67  
68 __END__
↑ Summary