blib/lib/File/Rename/Options.pm

filter: Statementstmt 90.0% 36 / 40 Branchbran 62.5% 10 / 16 Conditioncond 50.0% 3 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 8 / 8 Podpod 100% 2 / 2 totaltotal 80.0% 60 / 75 CC 10 SCAR 16.2
CC
10
Cov
79%
GetOptions
8.2
bad_encoding
4.5
BEGIN
1.0
CRAP 5.0
« blib/script/rename ↑ Summary Build »
1 package File::Rename::Options;
2
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶BEGIN { eval { require warnings; warnings->import } }
Subroutine BEGIN: called CC=1 SCAR=0.0
5
6 15 ▶use Getopt::Long ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 15 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 $VERSION = '1.10';
10
11 15 eval{ Getopt::Long::Configure qw(
12 posix_default
13 no_ignore_case
14 no_require_order
15 15 ▶ ); 1 } or do { require Carp; Carp::carp($@) };
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &Getopt::Long::Configure(("posix_default", "no_ignore_case", "no_require_order")); 1 } } or do { require Carp; Carp::carp($@) } 0 15 15
16
17 sub GetOptions {
18 19 ▶ my ($no_code) = @_;
Subroutine GetOptions: called CC=8 SCAR=21.1
Pod documented
19 19 my @expression;
20 19 my $fullpath = 1;
21 Getopt::Long::GetOptions(
22 '-v|verbose' => \my $verbose,
23 '-0|null' => \my $null,
24 '-n|nono' => \my $nono,
25 '-f|force' => \my $force,
26 '-h|?|help' => \my $help,
27 '-m|man' => \my $man,
28 '-V|version' => \my $version,
29 4 ▶ '-d|filename' => sub { undef $fullpath },
Subroutine __ANON__: called CC=1 SCAR=0.0
30 '-path|fullpath!' => \$fullpath,
31 '-e=s' => \@expression,
32 '-E=s' =>
33 sub {
34 4 ▶ my(undef, $e) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
35 4 $e .= ';';
36 4 push @expression, $e;
37 },
38 19 ▶ '-u|unicode:s' => \my $unicode,
Branch: 1 branch
BranchTrueFalseTotal
&Getopt::Long::GetOptions("-v|verbose", \my $verbose, "-0|null", \my $null, "-n|nono", \my $nono, "-f|force", \my $force, "-h|?|help", \my $help, "-m|man", \my $man, "-V|version", \my $version, "-d|filename", sub { undef $fullpath; } , "-path|fullpath!", \$fullpath, "-e=s", \@expression, "-E=s", sub { my(undef, $e) = @_; $e .= ';'; push @expression, $e; } , "-u|unicode:s", \my $unicode) or return 0 19 19
39 ) or return;
40
41 19 my $options = {
42 verbose => $verbose,
43 input_null => $null,
44 no_action => $nono,
45 over_write => $force,
46 filename_only => !$fullpath,
47 show_help => $help,
48 show_manual => $man,
49 show_version => $version,
50 unicode_strings => defined $unicode,
51 encoding => $unicode,
52 };
53 19 ▶ return $options if $no_code;
Branch: 1 branch
BranchTrueFalseTotal
if $no_code 6 13 19
54 13 ▶ return $options if $help or $man or $version;
Branch: 1 branch
BranchTrueFalseTotal
if $help or $man or $version 1 12 13
Condition50%3/6
$help or $man or $version
l!l&&r!l&&!r
0112
$help or $man
l!l&&r!l&&!r
0013
MC/DC33%1/3
$help or $man or $version
$help $man $version
Truth table50%2/4
A or B or C
A= $helpB= $manC= $version
ABCresult
1XX1
01X1
0011
0000
55
56 12 ▶ if( @expression ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@expression) { } 4 8 12
57 4 $options->{_code} = join "\n", @expression;
58 }
59 else {
60 8 ▶ return unless @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
unless @ARGV 0 8 8
61 8 $options->{_code} = shift @ARGV;
62 }
63 12 return $options;
64 }
65
66 sub bad_encoding {
67 11 ▶ my $options = shift;
Subroutine bad_encoding: called CC=3 SCAR=15.1
Pod documented
68 11 my $encoding = $options->{encoding};
69 11 ▶ return unless $encoding;
Branch: 1 branch
BranchTrueFalseTotal
unless $encoding 11 0 11
70 0 ▶ return unless $encoding =~ /[^\s\w.-]/;
Branch: 1 branch
BranchTrueFalseTotal
unless $encoding =~ /[^\s\w.-]/ 0 0 0
71 0 return 1
72 }
73
74 15 1;
75 __END__
« blib/script/rename ↑ Summary Build »