RPC/Legacy/Procedure.pm

filter: Statementstmt 28.5% 12 / 42 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 42.8% 3 / 7 Podpod 100% 1 / 1 totaltotal 21.6% 16 / 74 CC 12 SCAR 33.2
CC
12
Cov
19%
MODIFY_CODE_ATTRIBUTES
56.0
_parse_argument_type
20.0
check
6.0
CRAP 27.7
« RPC/Legacy/Server.pm ↑ Summary RPC/Legacy/Client.pm »
1 package JSON::RPC::Legacy::Procedure;
2  
3 #
4 # http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html
5 #
6  
7 2 $JSON::RPC::Legacy::Procedure::VERSION = '1.06';
8  
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use attributes;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 my $Procedure = {};
14  
15  
16 0 ▶sub check { $Procedure->{$_[0]} ? attributes::get($_[1]) : {}; }
Subroutine check: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$$Procedure{$_[0]} ? : 0 0 0
17  
18  
19 0 ▶sub FETCH_CODE_ATTRIBUTES {
Subroutine FETCH_CODE_ATTRIBUTES: not called CC=2 SCAR=17.9
20 0 my ($pkg, $code) = @_;
21 0 ▶ my $procedure = $Procedure->{$pkg}{$code} || { return_type => undef, argument_type => undef };
Condition0%0/2
$Procedure->{$pkg}{$code} || {'return_type', undef, 'argument_type', undef}
l!l
00
MC/DC0%0/1
$Procedure->{$pkg}{$code} || {'return_type', undef, 'argument_type', undef}
$Procedure->{$pkg}{$code}
Truth table0%0/2
A
A= $Procedure->{$pkg}{$code}
Aresult
11
00
22  
23 return {
24 return_type => $procedure->{return_type},
25 argument_type => $procedure->{argument_type},
26 0 };
27 }
28  
29  
30 0 ▶sub MODIFY_CODE_ATTRIBUTES {
Subroutine MODIFY_CODE_ATTRIBUTES: not called CC=7 SCAR=40.3
31 0 my ($pkg, $code, $attr) = @_;
32 0 my ($ret_type, $args);
33  
34 0 ▶ if ($attr =~ /^([A-Z][a-z]+)(?:\(\s*([^)]*)\s*\))?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr =~ /^([A-Z][a-z]+)(?:\(\s*([^)]*)\s*\))?$/) 0 0 0
35 0 ▶ $ret_type = $1 if (defined $1);
Branch: 1 branch
BranchTrueFalseTotal
if defined $1 0 0 0
36 0 ▶ $args = $2 if (defined $2);
Branch: 1 branch
BranchTrueFalseTotal
if defined $2 0 0 0
37 }
38  
39 0 ▶ unless ($ret_type =~ /^Private|Public|Arr|Obj|Bit|Bool|Num|Str|Nil|None/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ret_type =~ /^Private|Public|Arr|Obj|Bit|Bool|Num|Str|Nil|None/) 0 0 0
40 0 Carp::croak("Invalid type '$attr'. Specify 'Parivate' or 'Public' or One of JSONRPC Return Types.");
41 }
42  
43 0 ▶ if ($ret_type ne 'Private' and defined $args) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ret_type ne "Private" and defined $args) 0 0 0
Condition0%0/3
$ret_type ne "Private" and defined $args
!ll&&!rl&&r
000
MC/DC0%0/2
$ret_type ne "Private" and defined $args
$ret_type ne "Private" defined $args
Truth table0%0/3
A and B
A= $ret_type ne "Private"B= defined $args
ABresult
0X0
100
111
44 0 $Procedure->{$pkg}{$code}{argument_type} = _parse_argument_type($args);
45 }
46  
47 0 $Procedure->{$pkg}{$code}{return_type} = $ret_type;
48  
49 0 return;
50 }
51  
52  
53  
54 0 ▶sub _parse_argument_type {
Subroutine _parse_argument_type: not called CC=4 SCAR=30.0
55 0 my $text = shift;
56  
57 0 my $declaration;
58 my $pos;
59 0 my $name;
60  
61 0 $text =~ /^([,: a-zA-Z0-9]*)?$/;
62  
63 0 ▶ unless ( defined($declaration = $1) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined($declaration = $1)) 0 0 0
64 0 Carp::croak("Invalid argument type.");
65 }
66  
67 0 my @args = split/\s*,\s*/, $declaration;
68  
69 0 my $i = 0;
70  
71 0 $pos = [];
72 0 $name = {};
73  
74 0 for my $arg (@args) {
75 0 ▶ if ($arg =~ /([_0-9a-zA-Z]+)(?::([a-z]+))?/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg =~ /([_0-9a-zA-Z]+)(?::([a-z]+))?/) 0 0 0
76 0 push @$pos, $1;
77 0 $name->{$1} = $2;
78 }
79 }
80  
81 return {
82 0 position => $pos,
83 names => $name,
84 };
85 }
86  
87  
88  
89 2 1;
90 __END__
« RPC/Legacy/Server.pm ↑ Summary RPC/Legacy/Client.pm »