blib/lib/CAD/AutoCAD/Detect.pm

filter: Statementstmt 100% 35 / 35 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 94.6% 53 / 56 CC 5 SCAR 9.4
CC
5
Cov
95%
detect_dwg_file
5.0
__ANON__
1.0
BEGIN
1.0
CRAP 2.5
↑ Summary
1 package CAD::AutoCAD::Detect;
2  
3 3 ▶use base qw(Exporter);
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 ▶use CAD::AutoCAD::Version;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use List::MoreUtils qw(any);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # Constants.
13 3 Readonly::Array our @EXPORT => qw(detect_dwg_file);
14  
15 3 our $VERSION = 0.02;
16  
17 # Detect DWG file.
18 sub detect_dwg_file {
19 5 ▶ my $file = shift;
Subroutine detect_dwg_file: called CC=5 SCAR=16.1
Pod documented
20  
21 5 my $dwg_flag = 0;
22 5 ▶ open my $fh, '<', $file or err "Cannot open file '$file'.";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or err("Cannot open file '${file}'.") 1 4 5
23 4 my $magic;
24 4 my $read = read $fh, $magic, 6;
25 4 ▶ close $fh or err "Cannot close file '$file'.";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or err("Cannot close file '${file}'.") 0 4 4
26  
27 # Remove NULL characters from end of string.
28 4 $magic =~ s/\x00$//;
29  
30 4 ▶ if ($read == 6 && (any { $_ eq $magic }
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if ($read == 6 and &any(sub { $_ eq $magic; } , 'CAD::AutoCAD::Version'->list_of_acad_identifiers)) { } 3 1 4
Condition66%2/3
$read == 6 and &any(sub { $_ eq $magic; } , "CAD::AutoCAD::Version"->list_of_acad_identifiers)
!ll&&!rl&&r
103
MC/DC50%1/2
$read == 6 and &any(sub { $_ eq $magic; } , "CAD::AutoCAD::Version"->list_of_acad_identifiers)
$read == 6 &any(sub { $_ eq $magic; } , "CAD::AutoCAD::Version"->list_of_acad_identifiers)
Truth table66%2/3
A and B
A= $read == 6B= &any(sub { $_ eq $magic; } , "CAD::AutoCAD::Version"->list_of_acad_identifiers)
ABresult
0X0
100
111
31 CAD::AutoCAD::Version->list_of_acad_identifiers)) {
32  
33 3 return $magic;
34 } else {
35 1 return;
36 }
37 }
38  
39 3 1;
40  
41 __END__
↑ Summary