Babble/Plugin/DefinedOr.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 2 totaltotal 85.7% 30 / 35 CC 5 SCAR 8.9
CC
5
Cov
93%
__ANON__
3.0
__ANON__
3.0
check_bail_out_early
2.0
CRAP 2.4
« Babble/Plugin/CoreSignatures.pm ↑ Summary Babble/Plugin/State.pm »
1 package Babble::Plugin::DefinedOr;
2  
3 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 6 ▶sub transform_to_plain {
Subroutine transform_to_plain: called CC=1 SCAR=0.0
Pod undocumented
6 6 my ($self, $top) = @_;
7 $top->each_match_within(Statement => [
8 [ before => '(?>(?&PerlPrefixPostfixTerm))' ],
9 [ op => '(?>(?&PerlOWS) //=)' ], '(?>(?&PerlOWS))',
10 [ after => '(?>(?&PerlPrefixPostfixTerm))' ],
11 '(?>(?&PerlOWS))',
12 [ trail => '
13 (?&PerlStatementModifier)?+
14 (?>(?&PerlOWS))
15 (?> ; | (?= \} | \z ))
16 ' ],
17 2 ▶ ] => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
18 2 my ($m) = @_;
19 2 my ($before, $after, $trail) = $m->subtexts(qw(before after trail));
20 2 s/^\s+//, s/\s+$// for ($before, $after);
21 2 my $assign = 'defined($_) or $_ = '.$after.' for '.$before;
22 2 ▶ if (length($trail) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $trail > 1) 1 1 2
23 1 $assign = 'do { '.$assign.' } '
24 }
25 2 $m->replace_text($assign.$trail);
26 6 });
27 4 ▶ my $tf = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
28 4 my ($m) = @_;
29 4 my ($before, $after) = $m->subtexts(qw(before after));
30 4 s/^\s+//, s/\s+$// for ($before, $after);
31 4 ▶ if ($m->submatches->{op}->text =~ /=$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m->submatches->{"op"}->text =~ /=$/) 2 2 4
32 2 $after = '($_ = '.$after.')';
33 }
34 4 $m->replace_text('(map +(defined($_) ? $_ : '.$after.'), '.$before.')[0]');
35 6 };
36 6 $top->each_match_within(BinaryExpression => [
37 [ before => '(?>(?&PerlPrefixPostfixTerm))' ],
38 [ op => '(?>(?&PerlOWS) //)' ], '(?>(?&PerlOWS))',
39 [ after => '(?>(?&PerlPrefixPostfixTerm))' ],
40 ] => $tf);
41 6 $top->each_match_within(Assignment => [
42 [ before => '(?>(?&PerlConditionalExpression))' ],
43 [ op => '(?>(?&PerlOWS) //=)' ], '(?>(?&PerlOWS))',
44 [ after => '(?>(?&PerlConditionalExpression))' ],
45 ] => $tf);
46 }
47  
48 0 ▶sub check_bail_out_early {
Subroutine check_bail_out_early: not called CC=1 SCAR=6.9
Pod undocumented
49 0 my ($self, $top) = @_;
50 0 $top->text !~ m, // ,xs;
51 }
52  
53 1 1;
54 __END__
« Babble/Plugin/CoreSignatures.pm ↑ Summary Babble/Plugin/State.pm »