Nonogram/Base.pm

filter: Statementstmt 52.9% 18 / 34 Branchbran 27.7% 5 / 18 Conditioncond 40.0% 2 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 55.5% 5 / 9 Podpod 100% 7 / 7 totaltotal 50.0% 38 / 76 CC 12 SCAR 19.9
CC
12
Cov
44%
set_logfile
20.0
log
6.1
conf
6.0
CRAP 7.3
« Nonogram.pm ↑ Summary Nonogram/Line.pm »
1 package Games::Nonogram::Base;
2
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 7 my ($Conf, $Debug, $Stash, $Log);
7
8 0 ▶sub conf { shift; @_ ? $Conf = shift : $Conf; }
Subroutine conf: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
9 3 ▶sub debug { shift; @_ ? $Debug = shift : $Debug; }
Subroutine debug: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 3 3
10 0 ▶sub stash { $Stash ||= {} }
Subroutine stash: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/2
$Stash ||= {}
l!l
00
MC/DC0%0/1
$Stash ||= {}
$Stash
Truth table0%0/2
A
A= $Stash
Aresult
11
00
11
12 0 ▶sub clear_stash { $Stash = {} }
Subroutine clear_stash: not called CC=1 SCAR=6.9
Pod documented
13
14 0 ▶sub set_logfile {
Subroutine set_logfile: not called CC=4 SCAR=30.0
Pod documented
15 0 my ($self, $file) = @_;
16
17 0 ▶ if ( $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 0 0 0
18 0 eval {
19 0 require IO::File;
20 0 ▶ $Log = IO::File->new( $file, 'w' ) or die "$file cannot open";
Branch: 1 branch
BranchTrueFalseTotal
$Log = "IO::File"->new($file, "w") or die "$file cannot open" 0 0 0
21 0 $Log->autoflush;
22 };
23 }
24 else {
25 0 ▶ $Log->close if $Log;
Branch: 1 branch
BranchTrueFalseTotal
if $Log 0 0 0
26 0 undef $Log;
27 }
28 }
29
30 3 ▶sub log {
Subroutine log: called CC=3 SCAR=18.1
Pod documented
31 3 my ($self, @message) = @_;
32
33 3 ▶ return unless $Debug;
Branch: 1 branch
BranchTrueFalseTotal
unless $Debug 3 0 3
34
35 0 my ($package, $file, $line) = caller;
36
37 0 print STDERR @message, "\n";
38
39 0 ▶ if ( $Log ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Log) 0 0 0
40 0 print $Log @message, " at line $line in $package\n";
41 }
42 }
43
44 2 ▶sub range {
Subroutine range: called CC=4 SCAR=14.0
Pod documented
45 2 my ($self, %options) = @_;
46
47 2 ▶ my $from = $options{from} or die 'from is missing';
Branch: 1 branch
BranchTrueFalseTotal
my $from = $options{"from"} or die "from is missing" 2 0 2
48 2 my $to = $options{to};
49 2 my $length = $options{length};
50
51 2 ▶ $to = $from + $length - 1 if !$to && $length;
Branch: 1 branch
BranchTrueFalseTotal
if not $to and $length 1 1 2
Condition66%2/3
not $to and $length
!ll&&!rl&&r
101
MC/DC50%1/2
not $to and $length
not $to $length
Truth table66%2/3
not(A) and B
A= not $toB= $length
ABresult
0X0
100
111
52
53 2 return ( $from .. $to );
54 }
55
56 7 1;
57
58 __END__
« Nonogram.pm ↑ Summary Nonogram/Line.pm »