Introspector/Probe/MountPoints.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 6 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 88.6% 47 / 53 CC 6 SCAR 12.0
CC
6
Cov
95%
_parse_tab_fh
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
« Introspector/Util.pm ↑ Summary Introspector/Probe/LibDirs/Perl.pm »
1 package System::Introspector::Probe::MountPoints;
2 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use System::Introspector::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
5 handle_from_file
6 transform_exceptions
7 1 );
8  
9 1 ▶sub gather {
Subroutine gather: called CC=1 SCAR=0.0
Pod undocumented
10 1 my ($self) = @_;
11 return {
12 1 ▶ mtab => transform_exceptions {
Subroutine __ANON__: called CC=1 SCAR=0.0
13 1 return { entries
14 => $self->_parse_tab_fh($self->_open_fh('/etc/mtab')) };
15 },
16 1 ▶ fstab => transform_exceptions {
Subroutine __ANON__: called CC=1 SCAR=0.0
17 1 return { entries
18 => $self->_parse_tab_fh($self->_open_fh('/etc/fstab')) };
19 },
20 1 };
21 }
22  
23 2 ▶sub _open_fh {
Subroutine _open_fh: called CC=1 SCAR=0.0
24 2 my ($self, $file) = @_;
25 2 return handle_from_file $file;
26 }
27  
28 2 ▶sub _parse_tab_fh {
Subroutine _parse_tab_fh: called CC=6 SCAR=17.9
29 2 my ($self, $fh) = @_;
30 2 my @mounts;
31 2 ▶ while (defined( my $line = <$fh> )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 25 2 27
32 25 chomp $line;
33 25 ▶ next if $line =~ m{^\s*$}
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^\s*$/ or $line =~ /^\s*#/ 1 24 25
Condition66%2/3
$line =~ /^\s*$/ or $line =~ /^\s*#/
l!l&&r!l&&!r
0124
MC/DC50%1/2
$line =~ /^\s*$/ or $line =~ /^\s*#/
$line =~ /^\s*$/ $line =~ /^\s*#/
Truth table66%2/3
A or B
A= $line =~ /^\s*$/B= $line =~ /^\s*#/
ABresult
1X1
011
000
34 or $line =~ m{^\s*#};
35 24 my ($device, $point, $type, $opt, $dump, $pass)
36 = split m{\s+}, $line;
37 push @mounts, {
38 device_name => $device,
39 mount_point => $point,
40 fs_type => $type,
41 dump_freq => $dump,
42 pass_num => $pass,
43 options => {
44 map {
45 24 my ($name, $value) = split m{=}, $_, 2;
46 124 ▶ $value = 1
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 93 31 124
47 unless defined $value;
48 124 ($name => $value);
49 } split m{,}, $opt,
50 },
51 };
52 }
53 1 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
54 return [ sort {
55 2 ($a->{device_name} cmp $b->{device_name})
56 ||
57 ($a->{mount_point} cmp $b->{mount_point})
58 71 ▶ } @mounts ];
Condition66%2/3
$System::Introspector::Probe::MountPoints::a->{'device_name'} cmp $System::Introspector::Probe::MountPoints::b->{'device_name'} || $System::Introspector::Probe::MountPoints::a->{'mount_point'} cmp $System::Introspector::Probe::MountPoints::b->{'mount_point'}
l!l&&r!l&&!r
49220
MC/DC0%0/2
$System::Introspector::Probe::MountPoints::a->{'device_name'} cmp $System::Introspector::Probe::MountPoints::b->{'device_name'} || $System::Introspector::Probe::MountPoints::a->{'mount_point'} cmp $System::Introspector::Probe::MountPoints::b->{'mount_point'}
$System::Introspector::Probe::MountPoints::a->{'device_name'} cmp $System::Introspector::Probe::MountPoints::b->{'device_name'} $System::Introspector::Probe::MountPoints::a->{'mount_point'} cmp $System::Introspector::Probe::MountPoints::b->{'mount_point'}
Truth table66%2/3
A || B
A= $System::Introspector::Probe::MountPoints::a->{'device_name'} cmp $System::Introspector::Probe::MountPoints::b->{'device_name'}B= $System::Introspector::Probe::MountPoints::a->{'mount_point'} cmp $System::Introspector::Probe::MountPoints::b->{'mount_point'}
ABresult
1X1
011
000
59 }
60  
61 1 1;
62  
63 __END__
« Introspector/Util.pm ↑ Summary Introspector/Probe/LibDirs/Perl.pm »