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 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 ▶use warnings qw(FATAL all NONFATAL misc);
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 15 ▶use Exporter qw/import/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 15 our @EXPORT_OK = qw/format_entpath/;
8  
9 15 ▶use YATT::Lite::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use YATT::Lite::LRXML::ParseEntpath;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 15 *close_ch = *YATT::Lite::LRXML::ParseEntpath::close_ch;
12 15 *close_ch = *YATT::Lite::LRXML::ParseEntpath::close_ch;
13  
14 30 ▶sub inverse_hash {
Subroutine inverse_hash: called CC=3 SCAR=11.2
Pod undocumented
15 30 my ($fromHash, $toHash) = @_;
16 30 ▶ $toHash //= {};
Condition50%1/2
$toHash //= {}
l!l
300
MC/DC0%0/1
$toHash //= {}
$toHash
Truth table50%1/2
A
A= $toHash
Aresult
11
00
17 30 $toHash->{$fromHash->{$_}} = $_ for keys %$fromHash;
18 }
19  
20 15 our (%name2sym);
21 15 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
22 15 inverse_hash(\%name2sym, \%YATT::Lite::LRXML::ParseEntpath::open_head);
23 15 inverse_hash(\%name2sym, \%YATT::Lite::LRXML::ParseEntpath::open_rest);
24 }
25  
26 sub ME () {__PACKAGE__}
27 449 ▶sub format_entpath {
Subroutine format_entpath: called CC=2 SCAR=7.0
Pod undocumented
28 join("", map {
29 449 my ($type, @rest) = @{lxnest($_)};
30 490 ▶ 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)) 490 0 490
31 or Carp::croak "Unknown entpath type: ".YATT::Lite::Util::terse_dump($type);
32 490 $sub->(@rest);
33 } @_);
34 }
35  
36 102 ▶sub format__call {
Subroutine format__call: called CC=3 SCAR=11.0
Pod undocumented
37 102 my ($name, @args) = @_;
38 102 my @items = map {format_entpath(lxnest($_))} @args;
39 102 ▶ $items[-1] .= "," if @items and $items[-1] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if @items and $items[-1] eq "" 7 95 102
Condition100%3/3
@items and $items[-1] eq ""
!ll&&!rl&&r
44517
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 102 sprintf(":%s(%s)", $name, join(",", @items));
41 }
42  
43 15 *format__invoke = *format__call; *format__invoke = *format__call;
44  
45 154 ▶sub format__var {
Subroutine format__var: called CC=1 SCAR=0.0
Pod undocumented
46 154 my ($name) = @_;
47 154 ":$name";
48 }
49  
50 15 *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 15 *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 15 *format__array = *format__aref; *format__array = *format__aref;
65  
66 136 ▶sub format__text {
Subroutine format__text: called CC=3 SCAR=11.0
Pod undocumented
67 136 my ($name) = @_;
68 136 ▶ if ($name eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($name eq '') { } 10 126 136
elsif ($name =~ m[^[-\+\*/<>!\w\|\@\$%][-\+\*/<>!\w\|\@\$%=]*\z]) { } 121 5 126
69 10 "";
70 } elsif ($name =~ m{^[-\+\*/<>!\w\|\@\$%][-\+\*/<>!\w\|\@\$%=]*\z}) {
71 # XXX: matching paren {..}
72 121 $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 15 1;
« scripts/yatt.render ↑ Summary blib/lib/YATT/Lite/Util/CGICompat.pm »