Gitea/API/Issues.pm

filter: Statementstmt 48.5% 33 / 68 Branchbran 15.2% 7 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.3% 8 / 15 Podpod 100% 7 / 7 totaltotal 40.4% 55 / 136 CC 24 SCAR 25.6
CC
24
Cov
35%
create_comment
30.0
create
20.0
get
20.0
CRAP 12.9
« Gitea/API/Labels.pm ↑ Summary Gitea/API/Repos.pm »
1 package WWW::Gitea::API::Issues;
2  
3 # ABSTRACT: Gitea issues API (issues and issue comments)
4  
5 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use WWW::Gitea::Issue;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use WWW::Gitea::Comment;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 4 has client => (
13 is => 'ro',
14 required => 1,
15 weak_ref => 1,
16 );
17  
18  
19 has openapi_operations => (
20 is => 'lazy',
21 builder => sub {
22 return {
23 0 ▶ 'issues.list' => { method => 'GET', path => '/repos/{owner}/{repo}/issues' },
Subroutine __ANON__: not called CC=1 SCAR=1.2
Subroutine _build_openapi_operations: called CC=1 SCAR=1.2
24 'issues.create' => { method => 'POST', path => '/repos/{owner}/{repo}/issues' },
25 'issues.get' => { method => 'GET', path => '/repos/{owner}/{repo}/issues/{index}' },
26 'issues.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}/issues/{index}' },
27 'issues.search' => { method => 'GET', path => '/repos/issues/search' },
28 'issues.list_comments' => { method => 'GET', path => '/repos/{owner}/{repo}/issues/{index}/comments' },
29 'issues.create_comment' => { method => 'POST', path => '/repos/{owner}/{repo}/issues/{index}/comments' },
30 };
31 },
32 4 );
33  
34  
35 4 with 'WWW::Gitea::Role::OpenAPI';
36  
37 sub _wrap {
38 0 ▶ my ($self, $data, $owner, $repo) = @_;
Subroutine _wrap: not called CC=3 SCAR=24.8
39 0 ▶ return WWW::Gitea::Issue->new(
Branch: 2 branches
BranchTrueFalseTotal
defined $owner ? : 0 0 0
defined $repo ? : 0 0 0
40 client => $self->client,
41 data => $data,
42 (defined $owner ? (owner => $owner) : ()),
43 (defined $repo ? (repo => $repo) : ()),
44 );
45 }
46  
47 sub list {
48 1 ▶ my ($self, $owner, $repo, %query) = @_;
Subroutine list: called CC=4 SCAR=15.0
Pod documented
49 1 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 1 1
50 1 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 1 1
51 1 my $data = $self->call_operation('issues.list',
52 path => { owner => $owner, repo => $repo }, query => \%query);
53 1 ▶ return [ map { $self->_wrap($_, $owner, $repo) } @{ $data || [] } ];
Branch: 1 branch
BranchTrueFalseTotal
$data or [] 0 1 1
54 }
55  
56  
57 sub create {
58 0 ▶ my ($self, $owner, $repo, %args) = @_;
Subroutine create: not called CC=4 SCAR=30.0
Pod documented
59 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
60 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
61 0 ▶ croak 'title required' unless defined $args{title};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"title"} 0 0 0
62 0 my $data = $self->call_operation('issues.create',
63 path => { owner => $owner, repo => $repo }, body => \%args);
64 0 return $self->_wrap($data, $owner, $repo);
65 }
66  
67  
68 sub get {
69 0 ▶ my ($self, $owner, $repo, $index) = @_;
Subroutine get: not called CC=4 SCAR=30.0
Pod documented
70 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
71 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
72 0 ▶ croak 'index required' unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 0 0
73 0 my $data = $self->call_operation('issues.get',
74 path => { owner => $owner, repo => $repo, index => $index });
75 0 return $self->_wrap($data, $owner, $repo);
76 }
77  
78  
79 sub edit {
80 0 ▶ my ($self, $owner, $repo, $index, %args) = @_;
Subroutine edit: not called CC=4 SCAR=30.0
Pod documented
81 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
82 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
83 0 ▶ croak 'index required' unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 0 0
84 0 my $data = $self->call_operation('issues.edit',
85 path => { owner => $owner, repo => $repo, index => $index },
86 body => \%args);
87 0 return $self->_wrap($data, $owner, $repo);
88 }
89  
90  
91 sub search {
92 0 ▶ my ($self, %query) = @_;
Subroutine search: not called CC=2 SCAR=17.9
Pod documented
93 0 my $data = $self->call_operation('issues.search', query => \%query);
94 0 ▶ return [ map { $self->_wrap($_) } @{ $data || [] } ];
Branch: 1 branch
BranchTrueFalseTotal
$data or [] 0 0 0
95 }
96  
97  
98 sub comments {
99 1 ▶ my ($self, $owner, $repo, $index, %query) = @_;
Subroutine comments: called CC=5 SCAR=17.5
Pod documented
100 1 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 1 1
101 1 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 1 1
102 1 ▶ croak 'index required' unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 1 1
103 1 my $data = $self->call_operation('issues.list_comments',
104 path => { owner => $owner, repo => $repo, index => $index }, query => \%query);
105 return [ map {
106 0 WWW::Gitea::Comment->new(client => $self->client, data => $_)
107 1 ▶ } @{ $data || [] } ];
Branch: 1 branch
BranchTrueFalseTotal
$data or [] 0 1 1
108 }
109  
110  
111 sub create_comment {
112 0 ▶ my ($self, $owner, $repo, $index, $body) = @_;
Subroutine create_comment: not called CC=5 SCAR=34.0
Pod documented
113 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
114 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
115 0 ▶ croak 'index required' unless defined $index;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $index 0 0 0
116 0 ▶ croak 'body required' unless defined $body;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $body 0 0 0
117 0 my $data = $self->call_operation('issues.create_comment',
118 path => { owner => $owner, repo => $repo, index => $index },
119 body => { body => $body });
120 0 return WWW::Gitea::Comment->new(client => $self->client, data => $data);
121 }
122  
123  
124  
125 4 1;
126  
127 __END__
« Gitea/API/Labels.pm ↑ Summary Gitea/API/Repos.pm »