/usr/local/lib/perl5/site_perl/5.44.0/Sub/Exporter/Progressive.pm

filter: Statementstmt 90.1% 73 / 81 Branchbran 50.0% 11 / 22 Conditioncond 33.3% 5 / 15 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 70.8% 97 / 137 CC 22 SCAR 25.9
CC
22
Cov
75%
sub_export_options
19.0
__ANON__
12.5
_croak
2.0
CRAP 13.3
« /usr/local/lib/perl5/5.44.0/x86_64-linux/Unicode/Normalize.pm ↑ Summary /usr/local/lib/perl5/site_perl/5.44.0/Pod/Coverage/CountParents.pm »
1 package Sub::Exporter::Progressive;
2 7 $Sub::Exporter::Progressive::VERSION = '0.001013';
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 # ABSTRACT: Only use Sub::Exporter if you need it
7  
8 0 ▶sub _croak {
Subroutine _croak: not called CC=1 SCAR=6.9
9 0 require Carp;
10 0 &Carp::croak;
11 }
12  
13 14 ▶sub import {
Subroutine import: called CC=1 SCAR=0.2
14 14 my ($self, @args) = @_;
15  
16 14 my $inner_target = caller;
17 14 my $export_data = sub_export_options($inner_target, @args);
18  
19 14 my $full_exporter;
20 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 7 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 14 @{"${inner_target}::EXPORT_OK"} = @{$export_data->{exports}};
23 14 @{"${inner_target}::EXPORT"} = @{$export_data->{defaults}};
24 14 %{"${inner_target}::EXPORT_TAGS"} = %{$export_data->{tags}};
25 14 ▶ *{"${inner_target}::import"} = sub {
Subroutine __ANON__: called CC=7 SCAR=25.3
26 7 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 7 my ($self, @args) = @_;
28  
29 7 ▶ if ( grep {
Branch: 2 branches
BranchTrueFalseTotal
if (grep {length ref $_ or not $_ =~ / \A [:-]? \w+ \z /mx;} @args) { } 0 7 7
elsif (defined((my($num) = grep({/^\d/;} @args))[0])) { } 0 7 7
30 7 ▶ length ref $_
Condition33%1/3
length ref $_ || !($_ =~ / \A [:-]? \w+ \z /mx)
l!l&&r!l&&!r
007
MC/DC0%0/2
length ref $_ || !($_ =~ / \A [:-]? \w+ \z /mx)
length ref $_ !($_ =~ / \A [:-]? \w+ \z /mx)
Truth table33%1/3
A || not(B)
A= length ref $_B= !($_ =~ / \A [:-]? \w+ \z /mx)
ABresult
1X1
011
000
31 or
32 $_ !~ / \A [:-]? \w+ \z /xm
33 } @args ) {
34 _croak 'your usage of Sub::Exporter::Progressive requires Sub::Exporter to be installed'
35 0 ▶ unless eval { require Sub::Exporter };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { require Sub::Exporter } } 0 0 0
36 0 ▶ $full_exporter ||= Sub::Exporter::build_exporter($export_data->{original});
Condition0%0/3
$full_exporter ||= Sub::Exporter::build_exporter($export_data->{"original"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$full_exporter ||= Sub::Exporter::build_exporter($export_data->{"original"})
$full_exporter Sub::Exporter::build_exporter($export_data->{"original"})
Truth table0%0/3
A ||= B
A= $full_exporterB= Sub::Exporter::build_exporter($export_data->{"original"})
ABresult
1X1
011
000
37  
38 0 goto $full_exporter;
39 7 } elsif ( defined( (my ($num) = grep { m/^\d/ } @args)[0] ) ) {
40 0 _croak "cannot export symbols with a leading digit: '$num'";
41 } else {
42 7 require Exporter;
43 7 s/ \A - /:/xm for @args;
44 7 @_ = ($self, @args);
45 7 goto \&Exporter::import;
46 }
47 14 };
48 14 return;
49 }
50  
51 7 my $too_complicated = <<'DEATH';
52 You are using Sub::Exporter::Progressive, but the features your program uses from
53 Sub::Exporter cannot be implemented without Sub::Exporter, so you might as well
54 just use vanilla Sub::Exporter
55 DEATH
56  
57 14 ▶sub sub_export_options {
Subroutine sub_export_options: called CC=16 SCAR=29.5
Pod undocumented
58 14 my ($inner_target, $setup, $options) = @_;
59  
60 14 my @exports;
61 my @defaults;
62 14 my %tags;
63  
64 14 ▶ if ( ($setup||'') eq '-setup') {
Branch: 1 branch
BranchTrueFalseTotal
if (($setup || "") eq "-setup") 14 0 14
Condition50%1/2
$setup || ''
l!l
140
MC/DC0%0/1
$setup || ''
$setup
Truth table50%1/2
A
A= $setup
Aresult
11
00
65 14 my %options = %$options;
66  
67 OPTIONS:
68 14 for my $opt (keys %options) {
69 28 ▶ if ($opt eq 'exports') {
Branch: 2 branches
BranchTrueFalseTotal
if ($opt eq 'exports') { } 14 14 28
elsif ($opt eq 'groups') { } 14 0 14
70  
71 14 ▶ _croak $too_complicated if ref $options{exports} ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $options{"exports"} ne "ARRAY" 0 14 14
72 14 @exports = @{$options{exports}};
73 14 ▶ _croak $too_complicated if grep { length ref $_ } @exports;
Branch: 1 branch
BranchTrueFalseTotal
if grep {length ref $_;} @exports 0 14 14
74  
75 } elsif ($opt eq 'groups') {
76 14 %tags = %{$options{groups}};
77 14 for my $tagset (values %tags) {
78 _croak $too_complicated if grep {
79 14 ▶ length ref $_
Condition33%1/3
length ref $_ || $_ =~ / \A - (?! all \b ) /x
l!l&&r!l&&!r
0014
MC/DC0%0/2
length ref $_ || $_ =~ / \A - (?! all \b ) /x
length ref $_ $_ =~ / \A - (?! all \b ) /x
Truth table33%1/3
A || B
A= length ref $_B= $_ =~ / \A - (?! all \b ) /x
ABresult
1X1
011
000
80 or
81 $_ =~ / \A - (?! all \b ) /x
82 14 ▶ } @{$tagset};
Branch: 1 branch
BranchTrueFalseTotal
if grep {length ref $_ or $_ =~ / \A - (?! all \b ) /x;} @{$tagset;} 0 14 14
83 }
84 14 ▶ @defaults = @{$tags{default} || [] };
Condition50%1/2
$tags{'default'} || []
l!l
140
MC/DC0%0/1
$tags{'default'} || []
$tags{'default'}
Truth table50%1/2
A
A= $tags{'default'}
Aresult
11
00
85 } else {
86 0 _croak $too_complicated;
87 }
88 }
89 14 ▶ @{$_} = map { / \A [:-] all \z /x ? @exports : $_ } @{$_} for \@defaults, values %tags;
Branch: 1 branch
BranchTrueFalseTotal
/ \A [:-] all \z /x ? : 0 28 28
90 14 ▶ $tags{all} ||= [ @exports ];
Condition50%1/2
$tags{"all"} ||= [@exports]
l!l
014
MC/DC0%0/1
$tags{"all"} ||= [@exports]
$tags{"all"}
Truth table50%1/2
A
A= $tags{"all"}
Aresult
11
00
91 14 my %exports = map { $_ => 1 } @exports;
92 14 my @errors = grep { not $exports{$_} } @defaults;
93 14 ▶ _croak join(', ', @errors) . " is not exported by the $inner_target module\n" if @errors;
Branch: 1 branch
BranchTrueFalseTotal
if @errors 0 14 14
94 }
95  
96 return {
97 14 exports => \@exports,
98 defaults => \@defaults,
99 original => $options,
100 tags => \%tags,
101 };
102 }
103  
104 7 1;
105  
106 __END__
« /usr/local/lib/perl5/5.44.0/x86_64-linux/Unicode/Normalize.pm ↑ Summary /usr/local/lib/perl5/site_perl/5.44.0/Pod/Coverage/CountParents.pm »