blib/lib/YATT/Lite/LRXML/FormatEntpath.pm

filter: Statementstmt 100% 58 / 58 Branchbran 87.5% 7 / 8 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 8 totaltotal 88.5% 85 / 96 CC 8 SCAR 6.7
CC
8
Cov
97%
inverse_hash
3.1
format__call
3.0
format__text
3.0
CRAP 2.0
« scripts/yatt.render ↑ Summary blib/lib/YATT/Lite/Util/CGICompat.pm »
1 package YATT::Lite::LRXML::FormatEntpath;
2 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 9 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use Exporter qw/import/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 our @EXPORT_OK = qw/format_entpath/;
8  
9 9 ▶use YATT::Lite::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use YATT::Lite::LRXML::ParseEntpath;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 9 *close_ch = *YATT::Lite::LRXML::ParseEntpath::close_ch;
12 9 *close_ch = *YATT::Lite::LRXML::ParseEntpath::close_ch;
13  
14 18 ▶sub inverse_hash {
Subroutine inverse_hash: called CC=3 SCAR=11.2
Pod undocumented
15 18 my ($fromHash, $toHash) = @_;
16 18 ▶ $toHash //= {};
Condition50%1/2
$toHash //= {}
l!l
180
MC/DC0%0/1
$toHash //= {}
$toHash
Truth table50%1/2
A
A= $toHash
Aresult
11
00
17 18 $toHash->{$fromHash->{$_}} = $_ for keys %$fromHash;
18 }
19  
20 9 our (%name2sym);
21 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
22 9 inverse_hash(\%name2sym, \%YATT::Lite::LRXML::ParseEntpath::open_head);
23 9 inverse_hash(\%name2sym, \%YATT::Lite::LRXML::ParseEntpath::open_rest);
24 }
25  
26 sub ME () {__PACKAGE__}
27 368 ▶sub format_entpath {
Subroutine format_entpath: called CC=2 SCAR=7.0
Pod undocumented
28 join("", map {
29 368 my ($type, @rest) = @{lxnest($_)};
30 409 ▶ my $sub = ME->can("format__$type")
Branch: 1 branch
BranchTrueFalseTotal
my $sub = "YATT::Lite::LRXML::FormatEntpath"->can("format__$type") or Carp::croak('Unknown entpath type: ' . YATT::Lite::Util::terse_dump($type)) 409 0 409
31 or Carp::croak "Unknown entpath type: ".YATT::Lite::Util::terse_dump($type);
32 409 $sub->(@rest);
33 } @_);
34 }
35  
36 83 ▶sub format__call {
Subroutine format__call: called CC=3 SCAR=11.0
Pod undocumented
37 83 my ($name, @args) = @_;
38 83 my @items = map {format_entpath(lxnest($_))} @args;
39 83 ▶ $items[-1] .= "," if @items and $items[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if @items and $items[-1] eq "" 7 76 83
Condition100%3/3
@items and $items[-1] eq ""
!ll&&!rl&&r
30467
MC/DC100%2/2
@items and $items[-1] eq ""
@items $items[-1] eq ""
Truth table100%3/3
A and B
A= @itemsB= $items[-1] eq ""
ABresult
0X0
100
111
40 83 sprintf(":%s(%s)", $name, join(",", @items));
41 }
42  
43 9 *format__invoke = *format__call; *format__invoke = *format__call;
44  
45 107 ▶sub format__var {
Subroutine format__var: called CC=1 SCAR=0.0
Pod undocumented
46 107 my ($name) = @_;
47 107 ":$name";
48 }
49  
50 9 *format__prop = *format__var; *format__prop = *format__var;
51  
52 25 ▶sub format__href {
Subroutine format__href: called CC=1 SCAR=0.0
Pod undocumented
53 25 my (@args) = @_;
54 25 "{".join(",", map {format_entpath(lxnest($_))} @args)."}"
55 }
56  
57 9 *format__hash = *format__href; *format__hash = *format__href;
58  
59 29 ▶sub format__aref {
Subroutine format__aref: called CC=1 SCAR=0.0
Pod undocumented
60 29 my (@args) = @_;
61 29 "[".join(",", map {format_entpath(lxnest($_))} @args)."]"
62 }
63  
64 9 *format__array = *format__aref; *format__array = *format__aref;
65  
66 121 ▶sub format__text {
Subroutine format__text: called CC=3 SCAR=11.0
Pod undocumented
67 121 my ($name) = @_;
68 121 ▶ if ($name eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq '') { } 10 111 121
elsif ($name =~ m[^[-\+\*/<>!\w\|\@\$%][-\+\*/<>!\w\|\@\$%=]*\z]) { } 106 5 111
69 10 "";
70 } elsif ($name =~ m{^[-\+\*/<>!\w\|\@\$%][-\+\*/<>!\w\|\@\$%=]*\z}) {
71 # XXX: matching paren {..}
72 106 $name
73 } else {
74 5 "($name)"
75 }
76 }
77  
78 44 ▶sub format__expr {
Subroutine format__expr: called CC=1 SCAR=0.0
Pod undocumented
79 44 my ($name) = @_;
80 44 "=$name"
81 }
82  
83 9 1;
« scripts/yatt.render ↑ Summary blib/lib/YATT/Lite/Util/CGICompat.pm »