blib/lib/WebService/Bugzilla/Comment.pm

filter: Statementstmt 30.6% 23 / 75 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 27.2% 3 / 11 Podpod 100% 8 / 8 totaltotal 26.9% 34 / 126 CC 11 SCAR 21.2
CC
11
Cov
24%
get_by_id
12.0
get_reactions
12.0
render
12.0
CRAP 8.3
« blib/lib/WebService/Bugzilla/BugUserLastVisit.pm ↑ Summary blib/lib/WebService/Bugzilla/Role/Updatable.pm »
1 #!/usr/bin/false
2 # ABSTRACT: Bugzilla Comment object and service
3 # PODNAME: WebService::Bugzilla::Comment
4  
5 package WebService::Bugzilla::Comment 0.001;
6 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 extends 'WebService::Bugzilla::Object';
11  
12 1 has attachment_id => (is => 'ro');
13 1 has bug_id => (is => 'ro');
14 1 has count => (is => 'ro');
15 1 has creation_time => (is => 'ro');
16 1 has creator => (is => 'ro');
17 1 has is_markdown => (is => 'ro');
18 1 has is_private => (is => 'ro');
19 1 has raw_text => (is => 'ro');
20 1 has reactions => (is => 'ro');
21 1 has tags => (is => 'ro');
22 1 has text => (is => 'ro');
23 1 has time => (is => 'ro');
24  
25 0 ▶sub create {
Subroutine create: not called CC=1 SCAR=6.9
Pod documented
26 0 my ($self, $bug_id, %params) = @_;
27 0 my $res = $self->client->post($self->_mkuri("bug/$bug_id/comment"), \%params);
28 return $self->new(
29 client => $self->client,
30 id => $res->{id},
31 0 bug_id => $bug_id,
32 %params
33 );
34 }
35  
36 0 ▶sub get {
Subroutine get: not called CC=2 SCAR=17.9
Pod documented
37 0 my ($self, $bug_id) = @_;
38 0 my $res = $self->client->get($self->_mkuri("bug/$bug_id/comment"));
39 return [
40 map {
41 $self->new(
42 client => $self->client,
43 0 %{ $_ }
44 )
45 }
46 0 ▶ @{ $res->{bugs}{$bug_id}{comments} // [] }
Condition0%0/2
$res->{"bugs"}{$bug_id}{"comments"} // []
l!l
00
MC/DC0%0/1
$res->{"bugs"}{$bug_id}{"comments"} // []
$res->{"bugs"}{$bug_id}{"comments"}
Truth table0%0/2
A
A= $res->{"bugs"}{$bug_id}{"comments"}
Aresult
11
00
47 ];
48 }
49  
50 0 ▶sub get_by_id {
Subroutine get_by_id: not called CC=3 SCAR=24.8
Pod documented
51 0 my ($self, $comment_id) = @_;
52 0 my $res = $self->client->get($self->_mkuri("bug/comment/$comment_id"));
53 0 ▶ return unless $res->{comments} && %{ $res->{comments} };
Branch: 1 branch
BranchTrueFalseTotal
unless $res->{"comments"} and %{$res->{"comments"};} 0 0 0
Condition0%0/3
$res->{"comments"} and %{$res->{"comments"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$res->{"comments"} and %{$res->{"comments"};}
$res->{"comments"} %{$res->{"comments"};}
Truth table0%0/3
A and B
A= $res->{"comments"}B= %{$res->{"comments"};}
ABresult
0X0
100
111
54 0 my ($data) = values %{ $res->{comments} };
55 return $self->new(
56 client => $self->client,
57 0 %{ $data }
58 );
59 }
60  
61 0 ▶sub get_reactions {
Subroutine get_reactions: not called CC=3 SCAR=24.8
Pod documented
62 0 my ($self, $comment_id) = @_;
63 0 ▶ $comment_id //= $self->id;
Condition0%0/3
$comment_id //= $self->id
l!l&&r!l&&!r
000
MC/DC0%0/2
$comment_id //= $self->id
$comment_id $self->id
Truth table0%0/3
A //= B
A= $comment_idB= $self->id
ABresult
1X1
011
000
64 0 require WebService::Bugzilla::UserDetail;
65 0 my $res = $self->client->get($self->_mkuri("bug/comment/$comment_id/reactions"));
66 0 my %inflated;
67 0 for my $emoji (keys %{ $res }) {
68 $inflated{$emoji} = [
69 0 map { WebService::Bugzilla::UserDetail->new(%{ $_ }) } @{ $res->{$emoji} }
70 ];
71 }
72 0 return \%inflated;
73 }
74  
75 0 ▶sub render {
Subroutine render: not called CC=3 SCAR=24.8
Pod documented
76 0 my ($self, %params) = @_;
77 0 ▶ $params{id} //= $self->id if $self->has_id;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_id 0 0 0
Condition0%0/3
$params{"id"} //= $self->id
l!l&&r!l&&!r
000
MC/DC0%0/2
$params{"id"} //= $self->id
$params{"id"} $self->id
Truth table0%0/3
A //= B
A= $params{"id"}B= $self->id
ABresult
1X1
011
000
78 0 my $res = $self->client->post($self->_mkuri('bug/comment/render'), \%params);
79 0 return $res->{html};
80 }
81  
82 0 ▶sub search_tags {
Subroutine search_tags: not called CC=1 SCAR=6.9
Pod documented
83 0 my ($self, $query, %params) = @_;
84 0 my $res = $self->client->get($self->_mkuri("bug/comment/tags/$query"), \%params);
85 0 return $res;
86 }
87  
88 0 ▶sub update_reactions {
Subroutine update_reactions: not called CC=3 SCAR=24.8
Pod documented
89 0 my ($self, $comment_id, %params) = @_;
90 0 ▶ $comment_id //= $self->id;
Condition0%0/3
$comment_id //= $self->id
l!l&&r!l&&!r
000
MC/DC0%0/2
$comment_id //= $self->id
$comment_id $self->id
Truth table0%0/3
A //= B
A= $comment_idB= $self->id
ABresult
1X1
011
000
91 0 require WebService::Bugzilla::UserDetail;
92 0 my $res = $self->client->put($self->_mkuri("bug/comment/$comment_id/reactions"), \%params);
93 0 my %inflated;
94 0 for my $emoji (keys %{ $res }) {
95 $inflated{$emoji} = [
96 0 map { WebService::Bugzilla::UserDetail->new(%{ $_ }) } @{ $res->{$emoji} }
97 ];
98 }
99 0 return \%inflated;
100 }
101  
102 0 ▶sub update_tags {
Subroutine update_tags: not called CC=2 SCAR=17.9
Pod documented
103 0 my ($self, $comment_id, %params) = @_;
104 0 ▶ $comment_id //= $self->id;
Condition0%0/3
$comment_id //= $self->id
l!l&&r!l&&!r
000
MC/DC0%0/2
$comment_id //= $self->id
$comment_id $self->id
Truth table0%0/3
A //= B
A= $comment_idB= $self->id
ABresult
1X1
011
000
105 0 my $res = $self->client->put($self->_mkuri("bug/comment/$comment_id/tags"), \%params);
106 0 return $res;
107 }
108  
109 1 1;
110  
111 __END__
« blib/lib/WebService/Bugzilla/BugUserLastVisit.pm ↑ Summary blib/lib/WebService/Bugzilla/Role/Updatable.pm »