Receiver/Level2/Codespeed.pm

filter: Statementstmt 100% 36 / 36 Branchbran 60.0% 6 / 10 Conditioncond 44.4% 4 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 79.4% 54 / 68 CC 10 SCAR 20.7
CC
10
Cov
84%
submit
11.4
BEGIN
1.0
BEGIN
1.0
CRAP 8.0
↑ Summary Receiver/Daemon.pm »
1 package Tapper::Reports::Receiver::Level2::Codespeed;
2 2 our $AUTHORITY = 'cpan:TAPPER';
3 2 $Tapper::Reports::Receiver::Level2::Codespeed::VERSION = '5.0.2';
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Data::DPath 'dpath';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Scalar::Util "reftype";
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 sub submit
13 1 ▶{
Subroutine submit: called CC=10 SCAR=24.4
Pod documented
14 1 my ($util, $report, $options) = @_;
15  
16 1 my $codespeed_url = $options->{url};
17 1 my $subscribe_dpath = $options->{subscribe_dpath};
18  
19 1 ▶ return unless $codespeed_url && $subscribe_dpath;
Branch: 1 branch
BranchTrueFalseTotal
unless $codespeed_url and $subscribe_dpath 0 1 1
Condition33%1/3
$codespeed_url and $subscribe_dpath
!ll&&!rl&&r
001
MC/DC0%0/2
$codespeed_url and $subscribe_dpath
$codespeed_url $subscribe_dpath
Truth table33%1/3
A and B
A= $codespeed_urlB= $subscribe_dpath
ABresult
0X0
100
111
20  
21 1 my $max_retry = 5;
22 1 my $tap_dom = $report->get_cached_tapdom;
23 1 my @chunks = dpath($subscribe_dpath)->match($tap_dom);
24 1 ▶ @chunks = @{$chunks[0]} while $chunks[0] && reftype $chunks[0] eq "ARRAY"; # deref all array envelops
Branch: 1 branch
BranchTrueFalseTotal
$chunks[0] and builtin::reftype($chunks[0]) eq "ARRAY" and do { @chunks = @{$chunks[0];} } 1 1 2
Condition66%2/3
$chunks[0] and builtin::reftype($chunks[0]) eq "ARRAY"
!ll&&!rl&&r
011
MC/DC50%1/2
$chunks[0] and builtin::reftype($chunks[0]) eq "ARRAY"
$chunks[0] builtin::reftype($chunks[0]) eq "ARRAY"
Truth table66%2/3
A and B
A= $chunks[0]B= builtin::reftype($chunks[0]) eq "ARRAY"
ABresult
0X0
100
111
25  
26 1 ▶ return unless @chunks;
Branch: 1 branch
BranchTrueFalseTotal
unless @chunks 0 1 1
27  
28 1 my $ua = LWP::UserAgent->new;
29 1 $ua->timeout(10);
30 1 foreach my $chunk (@chunks) {
31 4 my $response;
32 4 my $retry = $max_retry;
33 4 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
not $response->is_success and $retry-- and do { do { $response = $ua->post($codespeed_url . '/result/add/', $chunk) } } 0 4 4
Condition33%1/3
not $response->is_success and $retry--
!ll&&!rl&&r
400
MC/DC0%0/2
not $response->is_success and $retry--
not $response->is_success $retry--
Truth table33%1/3
not(A) and B
A= not $response->is_successB= $retry--
ABresult
0X0
100
111
34 4 $response = $ua->post($codespeed_url."/result/add/", $chunk);
35 } while ( !$response->is_success and $retry-- );
36 4 ▶ $util->log->warn("Submit to $codespeed_url FAILED.") if !$response->is_success;
Branch: 1 branch
BranchTrueFalseTotal
unless $response->is_success 0 4 4
37 }
38 }
39  
40 2 1;
41  
42 __END__
↑ Summary Receiver/Daemon.pm »