Ext/Common.pm

filter: Statementstmt 81.8% 18 / 22 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 78.7% 26 / 33 CC 4 SCAR 12.5
CC
4
Cov
75%
walk
5.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« Ext/MsgPack/RPC/EventLoop.pm ↑ Summary Ext/Plugin.pm »
1 package Neovim::Ext::Common;
2 55 $Neovim::Ext::Common::VERSION = '0.01';
3 55 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 55 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 55 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 55 our @EXPORT_OK = qw/walk/;
8  
9  
10 sub walk
11 {
12 48 ▶ my ($sub, $obj, @args) = @_;
Subroutine walk: called CC=4 SCAR=16.8
Pod documented
13  
14 48 ▶ if (ref ($obj) eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj eq "ARRAY") 19 29 48
15 {
16 19 return [map { walk ($sub, $_, @args) } @$obj];
17 }
18  
19 29 ▶ if (ref ($obj) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj eq "HASH") 0 29 29
20 {
21 0 my %result;
22 0 ▶ while (my ($key, $value) = each %$obj)
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$obj) 0 0 0
23 {
24 0 $result{walk ($sub, $key, @args)} = walk ($sub, $value, @args);
25 }
26  
27 0 return \%result;
28 }
29  
30 29 return $sub->($obj, @args);
31 }
32  
33 =head1 NAME
34  
35 Neovim::Ext::Common - Common functions
36  
37 =head1 VERSION
38  
39 version 0.01
40  
41 =head1 FUNCTIONS
42  
43 =head2 walk( \&sub, $obj, @args)
44  
45 Walk C<$obj> recursively, calling C<\&sub> with C<$obj> and C<@args>.
46  
47 =cut
48  
49 55 1;
« Ext/MsgPack/RPC/EventLoop.pm ↑ Summary Ext/Plugin.pm »