examples/HTTP/API/Core/Example/Jira.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 72.7% 16 / 22 Conditioncond 61.1% 11 / 18 MC/DCmcdc 30.0% 3 / 10 Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 76.0% 70 / 92 CC 19 SCAR 23.4
CC
19
Cov
81%
issues_pager
14.5
new
8.0
BEGIN
1.0
CRAP 10.3
« blib/lib/HTTP/API/Core/Response.pm ↑ Summary blib/lib/HTTP/API/Core/Error.pm »
1 package HTTP::API::Core::Example::Jira;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use parent 'HTTP::API::Core';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use HTTP::API::Core::Auth qw(basic_auth);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # A small Jira Server/Data Center search recipe, not an official SDK.
9 3 ▶sub new {
Subroutine new: called CC=7 SCAR=20.8
Pod documented
10 3 my ($class, %args) = @_;
11 3 my $username = delete $args{username};
12 3 my $password = delete $args{password};
13 3 ▶ die "username is required\n" if !defined($username) || ref($username) ne '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $username or ref $username ne "" 0 3 3
Condition33%1/3
not defined $username or ref $username ne ""
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $username or ref $username ne ""
not defined $username ref $username ne ""
Truth table33%1/3
not(A) or B
A= not defined $usernameB= ref $username ne ""
ABresult
1X1
011
000
14 3 ▶ die "password is required\n" if !defined($password) || ref($password) ne '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $password or ref $password ne "" 1 2 3
Condition66%2/3
not defined $password or ref $password ne ""
l!l&&r!l&&!r
102
MC/DC50%1/2
not defined $password or ref $password ne ""
not defined $password ref $password ne ""
Truth table66%2/3
not(A) or B
A= not defined $passwordB= ref $password ne ""
ABresult
1X1
011
000
15 2 ▶ die "base_url is required\n" if !defined($args{base_url});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"base_url"} 0 2 2
16 die "custom hooks are not supported by this example\n"
17 2 ▶ if exists $args{hooks};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"hooks"} 0 2 2
18  
19 2 return $class->SUPER::new(
20 %args,
21 hooks => { before_request => basic_auth($username, $password) },
22 );
23 }
24  
25 5 ▶sub issues_pager {
Subroutine issues_pager: called CC=13 SCAR=26.7
Pod undocumented
26 5 my ($self, %args) = @_;
27 5 my $jql = delete $args{jql};
28 5 ▶ die "jql must be a non-empty scalar\n"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $jql or ref $jql ne "" or $jql eq "" 1 4 5
Condition66%4/6
not defined $jql or ref $jql ne "" or $jql eq ""
l!l&&r!l&&!r
104
not defined $jql or ref $jql ne ""
l!l&&r!l&&!r
104
MC/DC33%1/3
not defined $jql or ref $jql ne "" or $jql eq ""
not defined $jql ref $jql ne "" $jql eq ""
Truth table50%2/4
not(A) or B or C
A= not defined $jqlB= ref $jql ne ""C= $jql eq ""
ABCresult
1XX1
01X1
0011
0000
29 if !defined($jql) || ref($jql) ne '' || $jql eq '';
30  
31 4 my $fields = delete $args{fields};
32 4 ▶ if (defined $fields) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields) 2 2 4
33 2 ▶ if (ref($fields) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $fields eq 'ARRAY') { } 2 0 2
elsif (ref $fields ne '') { } 0 0 0
34 die "fields must contain only non-empty scalars\n"
35 2 ▶ if grep { !defined($_) || ref($_) ne '' || $_ eq '' } @$fields;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not defined $_ or ref $_ ne "" or $_ eq "";} @$fields 1 1 2
Condition66%4/6
!defined($_) || ref $_ ne '' || $_ eq ''
l!l&&r!l&&!r
103
not defined $_ or ref $_ ne ""
l!l&&r!l&&!r
013
MC/DC33%1/3
!defined($_) || ref $_ ne '' || $_ eq ''
not defined $_ ref $_ ne "" $_ eq ''
Truth table50%2/4
not(A) or B || C
A= not defined $_B= ref $_ ne ""C= $_ eq ''
ABCresult
1XX1
01X1
0011
0000
36 1 $fields = join(',', @$fields);
37 }
38 elsif (ref($fields) ne '') {
39 0 die "fields must be a string or array reference\n";
40 }
41 }
42  
43 my $max_results = exists($args{max_results})
44 3 ▶ ? delete($args{max_results}) : 100;
Branch: 1 branch
BranchTrueFalseTotal
exists $args{'max_results'} ? : 1 2 3
45 3 die "unknown issues_pager option: $_\n" for sort keys %args;
46  
47 2 ▶ return $self->paginate(
Branch: 1 branch
BranchTrueFalseTotal
defined $fields ? : 1 1 2
48 '/rest/api/2/search',
49 mode => 'offset',
50 items => 'issues',
51 total => 'total',
52 offset_param => 'startAt',
53 page_size_param => 'maxResults',
54 page_size => $max_results,
55 query => {
56 jql => $jql,
57 (defined($fields) ? (fields => $fields) : ()),
58 },
59 );
60 }
61  
62 1 1;
« blib/lib/HTTP/API/Core/Response.pm ↑ Summary blib/lib/HTTP/API/Core/Error.pm »