API/Validator/Visitor.pm

filter: Statementstmt 93.1% 54 / 58 Branchbran 78.5% 11 / 14 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 87.6% 78 / 89 CC 10 SCAR 10.1
CC
10
Cov
88%
__ANON__
4.4
visit_array_entry
3.0
__ANON__
3.0
CRAP 2.8
« API/StoredResultSource.pm ↑ Summary API/StaticArguments.pm »
1 package Catalyst::Controller::DBIC::API::Validator::Visitor;
2 16 $Catalyst::Controller::DBIC::API::Validator::Visitor::VERSION = '2.009000';
3 #ABSTRACT: Provides validation services for inbound requests against whitelisted parameters
4 16 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 16 ▶BEGIN { extends 'Data::DPath::Validator::Visitor'; }
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 16 ▶use constant DEBUG => $ENV{DATA_DPATH_VALIDATOR_DEBUG} || 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Condition50%1/2
$ENV{'DATA_DPATH_VALIDATOR_DEBUG'} || 0
l!l
016
MC/DC0%0/1
$ENV{'DATA_DPATH_VALIDATOR_DEBUG'} || 0
$ENV{'DATA_DPATH_VALIDATOR_DEBUG'}
Truth table50%1/2
A
A= $ENV{'DATA_DPATH_VALIDATOR_DEBUG'}
Aresult
11
00
11  
12 46 ▶around visit_array => sub {
Subroutine __ANON__: called CC=4 SCAR=14.9
13 46 my ( $orig, $self, $array ) = @_;
14 46 $self->dive();
15 46 warn 'ARRAY: ' . $self->current_template if DEBUG;
16 46 ▶ if ( @$array == 1 && $array->[0] eq '*' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$array == 1 and $array->[0] eq '*') { } 23 23 46
Condition66%2/3
@$array == 1 and $array->[0] eq "*"
!ll&&!rl&&r
23023
MC/DC50%1/2
@$array == 1 and $array->[0] eq "*"
@$array == 1 $array->[0] eq "*"
Truth table66%2/3
A and B
A= @$array == 1B= $array->[0] eq "*"
ABresult
0X0
100
111
17 23 $self->append_text('[reftype eq "HASH" ]');
18 23 $self->add_template( $self->current_template );
19 }
20 else {
21 23 ▶ if ( $self->current_template =~ /\/$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current_template =~ m[/$]) 0 23 23
22 0 my $temp = $self->current_template;
23 0 $self->reset_template();
24 0 $temp =~ s/\/$//;
25 0 $self->append_text($temp);
26 }
27 23 $self->$orig($array);
28 }
29 46 $self->rise();
30 16 };
31  
32 92 ▶sub visit_array_entry {
Subroutine visit_array_entry: called CC=3 SCAR=11.0
Pod documented
33  
34 # to make release-unused-vars.t happy
35 #my ($self, $elem, $index, $array) = @_;
36 92 my ( $self, $elem ) = @_;
37 92 $self->dive();
38 92 warn 'ARRAYENTRY: ' . $self->current_template if DEBUG;
39 92 ▶ if ( !ref($elem) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $elem) { } 69 23 92
elsif (ref $elem eq 'HASH') { } 23 0 23
40 69 $self->append_text( $elem . '/*' );
41 69 $self->add_template( $self->current_template );
42 }
43 elsif ( ref($elem) eq 'HASH' ) {
44 23 $self->visit($elem);
45 }
46 92 $self->rise();
47 92 $self->value_type('NONE');
48 }
49  
50 47 ▶around visit_hash => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
51 47 my ( $orig, $self, $hash ) = @_;
52 47 $self->dive();
53 47 ▶ if ( $self->current_template =~ /\/$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->current_template =~ m[/$]) 47 0 47
54 47 my $temp = $self->current_template;
55 47 $self->reset_template();
56 47 $temp =~ s/\/$//;
57 47 $self->append_text($temp);
58 }
59 47 warn 'HASH: ' . $self->current_template if DEBUG;
60 47 $self->$orig($hash);
61 47 $self->rise();
62 16 };
63  
64 107 ▶around visit_value => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
65 107 my ( $orig, $self, $val ) = @_;
66  
67 107 ▶ if ( $self->value_type eq 'NONE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->value_type eq 'NONE') { } 59 48 107
elsif ($self->value_type eq 'HashKey') { } 47 1 48
68 59 $self->dive();
69 59 $self->append_text( $val . '/*' );
70 59 $self->add_template( $self->current_template );
71 59 warn 'VALUE: ' . $self->current_template if DEBUG;
72 59 $self->rise();
73 }
74 elsif ( $self->value_type eq 'HashKey' ) {
75 47 $self->append_text($val);
76 47 warn 'VALUE: ' . $self->current_template if DEBUG;
77 }
78 else {
79 1 $self->$orig($val);
80 }
81  
82 16 };
83  
84 16 __PACKAGE__->meta->make_immutable;
85  
86 16 1;
87  
88 __END__
« API/StoredResultSource.pm ↑ Summary API/StaticArguments.pm »