Gitea/API/Labels.pm

filter: Statementstmt 47.0% 24 / 51 Branchbran 5.8% 2 / 34 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 58.3% 7 / 12 Podpod 100% 5 / 5 totaltotal 37.1% 39 / 105 CC 19 SCAR 27.1
CC
19
Cov
31%
create
30.0
get
20.0
edit
20.0
CRAP 15.0
« Gitea/API/Milestones.pm ↑ Summary Gitea/API/Repos.pm »
1 package WWW::Gitea::API::Labels;
2  
3 # ABSTRACT: Gitea repository labels API
4  
5 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use WWW::Gitea::Label;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 5 has client => (
12 is => 'ro',
13 required => 1,
14 weak_ref => 1,
15 );
16  
17  
18 has openapi_operations => (
19 is => 'lazy',
20 1 ▶ builder => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine _build_openapi_operations: called CC=1 SCAR=0.0
21 return {
22 1 'labels.list' => { method => 'GET', path => '/repos/{owner}/{repo}/labels' },
23 'labels.create' => { method => 'POST', path => '/repos/{owner}/{repo}/labels' },
24 'labels.get' => { method => 'GET', path => '/repos/{owner}/{repo}/labels/{id}' },
25 'labels.edit' => { method => 'PATCH', path => '/repos/{owner}/{repo}/labels/{id}' },
26 'labels.delete' => { method => 'DELETE', path => '/repos/{owner}/{repo}/labels/{id}' },
27 };
28 },
29 5 );
30  
31  
32 5 with 'WWW::Gitea::Role::OpenAPI';
33  
34 0 ▶sub _wrap {
Subroutine _wrap: not called CC=3 SCAR=24.8
35 0 my ($self, $data, $owner, $repo) = @_;
36 0 ▶ return WWW::Gitea::Label->new(
Branch: 2 branches
BranchTrueFalseTotal
defined $owner ? : 0 0 0
defined $repo ? : 0 0 0
37 client => $self->client,
38 data => $data,
39 (defined $owner ? (owner => $owner) : ()),
40 (defined $repo ? (repo => $repo) : ()),
41 );
42 }
43  
44 2 ▶sub list {
Subroutine list: called CC=4 SCAR=15.0
Pod documented
45 2 my ($self, $owner, $repo, %query) = @_;
46 2 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 2 2
47 2 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 2 2
48 2 my $data = $self->call_operation('labels.list',
49 path => { owner => $owner, repo => $repo }, query => \%query);
50 0 ▶ return [ map { $self->_wrap($_, $owner, $repo) } @{ $data || [] } ];
Condition50%1/2
$data || []
l!l
20
MC/DC0%0/1
$data || []
$data
Truth table50%1/2
A
A= $data
Aresult
11
00
51 }
52  
53  
54 0 ▶sub create {
Subroutine create: not called CC=5 SCAR=34.0
Pod documented
55 0 my ($self, $owner, $repo, %args) = @_;
56 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
57 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
58 0 ▶ croak 'name required' unless defined $args{name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"name"} 0 0 0
59 0 ▶ croak 'color required' unless defined $args{color};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"color"} 0 0 0
60 0 my $data = $self->call_operation('labels.create',
61 path => { owner => $owner, repo => $repo }, body => \%args);
62 0 return $self->_wrap($data, $owner, $repo);
63 }
64  
65  
66 0 ▶sub get {
Subroutine get: not called CC=4 SCAR=30.0
Pod documented
67 0 my ($self, $owner, $repo, $id) = @_;
68 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
69 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
70 0 ▶ croak 'id required' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
71 0 my $data = $self->call_operation('labels.get',
72 path => { owner => $owner, repo => $repo, id => $id });
73 0 return $self->_wrap($data, $owner, $repo);
74 }
75  
76  
77 0 ▶sub edit {
Subroutine edit: not called CC=4 SCAR=30.0
Pod documented
78 0 my ($self, $owner, $repo, $id, %args) = @_;
79 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
80 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
81 0 ▶ croak 'id required' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
82 0 my $data = $self->call_operation('labels.edit',
83 path => { owner => $owner, repo => $repo, id => $id }, body => \%args);
84 0 return $self->_wrap($data, $owner, $repo);
85 }
86  
87  
88 0 ▶sub delete {
Subroutine delete: not called CC=4 SCAR=30.0
Pod documented
89 0 my ($self, $owner, $repo, $id) = @_;
90 0 ▶ croak 'owner required' unless defined $owner;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owner 0 0 0
91 0 ▶ croak 'repo required' unless defined $repo;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $repo 0 0 0
92 0 ▶ croak 'id required' unless defined $id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id 0 0 0
93 0 return $self->call_operation('labels.delete',
94 path => { owner => $owner, repo => $repo, id => $id });
95 }
96  
97  
98  
99 5 1;
100  
101 __END__
« Gitea/API/Milestones.pm ↑ Summary Gitea/API/Repos.pm »