blib/lib/File/IsSorted.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 4 / 4 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 93.1% 54 / 58 CC 5 SCAR 7.4
CC
5
Cov
95%
is_filehandle_sorted
4.0
is_file_sorted
2.1
BEGIN
1.0
CRAP 2.1
« blib/lib/App/File/IsSorted/Command/check.pm ↑ Summary blib/lib/App/File/IsSorted.pm »
1 package File::IsSorted;
2 5 $File::IsSorted::VERSION = '0.0.5';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶no locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 ▶use Path::Tiny qw/ path /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 sub is_filehandle_sorted
14 {
15 5 ▶ my ( $self, $args ) = @_;
Subroutine is_filehandle_sorted: called CC=4 SCAR=13.9
Pod documented
16  
17 5 my $fh = $args->{fh};
18 5 ▶ my $id = $args->{id} // 'unknown';
Condition100%2/2
$args->{"id"} // "unknown"
l!l
41
MC/DC100%1/1
$args->{"id"} // "unknown"
$args->{"id"}
Truth table100%2/2
A
A= $args->{"id"}
Aresult
11
00
19  
20 5 my $prev = <$fh>;
21 5 ▶ while ( my $l = <$fh> )
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $l = readline $fh)) 15 4 19
22 {
23 15 ▶ if ( $l le $prev )
Branch: 1 branch
BranchTrueFalseTotal
if ($l le $prev) 1 14 15
24 {
25 1 die "<$l> less-or-equal than <$prev> in $id!";
26 }
27 }
28 continue
29 {
30 14 $prev = $l;
31 }
32  
33 4 return 1;
34 }
35  
36 sub is_file_sorted
37 {
38 4 ▶ my ( $self, $args ) = @_;
Subroutine is_file_sorted: called CC=2 SCAR=7.4
Pod documented
39  
40 4 my $path = $args->{path};
41 4 ▶ my $id = $args->{id} // $path;
Condition33%1/3
$args->{"id"} // $path
l!l&&r!l&&!r
040
MC/DC0%0/2
$args->{"id"} // $path
$args->{"id"} $path
Truth table33%1/3
A // B
A= $args->{"id"}B= $path
ABresult
1X1
011
000
42  
43 4 return $self->is_filehandle_sorted(
44 { fh => path($path)->openr, id => $id } );
45 }
46  
47 5 1;
48  
49 __END__
« blib/lib/App/File/IsSorted/Command/check.pm ↑ Summary blib/lib/App/File/IsSorted.pm »