scripts/file-pp.pl

filter: Statementstmt 80.0% 32 / 40 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.9% 10 / 11 Podpod n/a totaltotal 74.1% 46 / 62 CC 6 SCAR 17.2
CC
6
Cov
73%
main
13.0
logmsg
2.0
BEGIN
1.0
CRAP 5.6
↑ Summary lib/File/MagicPP.pm »
1 #!/usr/bin/env perl
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Basename qw/basename/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use FindBin qw/$RealBin/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use lib "$RealBin/../lib";
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::MagicPP qw/file $VERSION/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 local $0 = basename $0;
15 0 ▶sub logmsg{local $0=basename $0; print STDERR "$0: @_\n";}
Subroutine logmsg: not called CC=1 SCAR=6.9
16 1 exit(main());
17  
18 1 ▶sub main{
Subroutine main: called CC=6 SCAR=25.6
19 1 my $settings={};
20 1 ▶ GetOptions($settings,qw(help version)) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions($settings, ("help", "version")) or die $! 1 0 1
21 1 ▶ if($$settings{version}){
Branch: 1 branch
BranchTrueFalseTotal
if ($settings->{"version"}) 0 1 1
22 0 print basename($0)." v$VERSION\n";
23 0 return 0;
24 }
25
26 1 ▶ usage() if(!@ARGV || $$settings{help});
Branch: 1 branch
BranchTrueFalseTotal
if not @ARGV or $settings->{"help"} 1 0 1
Condition33%1/3
not @ARGV or $settings->{"help"}
l!l&&r!l&&!r
100
MC/DC0%0/2
not @ARGV or $settings->{"help"}
not @ARGV $settings->{"help"}
Truth table33%1/3
not(A) or B
A= not @ARGVB= $settings->{"help"}
ABresult
1X1
011
000
27  
28 0 for my $file(@ARGV){
29 0 print file($file);
30 0 print "\n";
31 }
32  
33 0 return 0;
34 }
35  
36 1 ▶sub usage{
Subroutine usage: called CC=1 SCAR=0.0
37 1 print "$0: determines file type from magic
38 Usage: $0 [options] file
39 --version Print version and exit
40 --help This useful help menu
41 \n";
42 1 exit 0;
43 }
↑ Summary lib/File/MagicPP.pm »