MergeVelocity/Repository/Statistics.pm

filter: Statementstmt 100% 33 / 33 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 90.0% 45 / 50 CC 4 SCAR 4.2
CC
4
Cov
92%
__ANON__
2.1
percentage_in_state
2.0
average_age_for_state
2.0
CRAP 1.5
« MergeVelocity/Repository.pm ↑ Summary MergeVelocity/Types.pm »
1 package GitHub::MergeVelocity::Repository::Statistics;
2 3 our $VERSION = '0.000008';
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use Math::Round qw( nearest round );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Types::Standard qw( Bool Int );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 has average_velocity => (
11 is => 'ro',
12 isa => Int,
13 lazy => 1,
14 default => sub {
15 1 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=7.2
16 1 ▶ return $self->pull_request_count
Branch: 1 branch
BranchTrueFalseTotal
$self->pull_request_count ? : 1 0 1
17 ? round( $self->total_velocity / $self->pull_request_count )
18 : 0;
19 },
20 3 );
21  
22 3 has [ 'closed', 'open', 'merged', ] => (
23 is => 'ro',
24 isa => Int,
25 default => 0,
26 );
27  
28 3 has [ 'closed_age', 'open_age', 'merged_age' ] => (
29 is => 'ro',
30 isa => Int,
31 default => 0,
32 );
33  
34 has pull_request_count => (
35 is => 'ro',
36 isa => Int,
37 lazy => 1,
38 default => sub {
39 2 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
40 2 return $self->closed + $self->open + $self->merged;
41 },
42 3 );
43  
44 3 has total_velocity => (
45 is => 'ro',
46 isa => Int,
47 required => 1,
48 );
49  
50 sub average_age_for_state {
51 3 ▶ my $self = shift;
Subroutine average_age_for_state: called CC=2 SCAR=7.0
Pod undocumented
52 3 my $state = shift;
53  
54 3 my $method = $state . '_age';
55 3 ▶ return $self->$method
Branch: 1 branch
BranchTrueFalseTotal
$self->$method ? : 3 0 3
56 ? round( $self->$method / $self->$state )
57 : 0;
58 }
59  
60 sub percentage_in_state {
61 6 ▶ my $self = shift;
Subroutine percentage_in_state: called CC=2 SCAR=7.1
Pod undocumented
62 6 my $state = shift;
63 6 ▶ return $self->pull_request_count
Branch: 1 branch
BranchTrueFalseTotal
$self->pull_request_count ? : 6 0 6
64 ? nearest( 0.01, $self->$state / $self->pull_request_count )
65 : 0;
66 }
67  
68 3 1;
69  
70 =pod
71  
72 =encoding UTF-8
73  
74 =head1 NAME
75  
76 GitHub::MergeVelocity::Repository::Statistics - Pull request statistics for a given repository
77  
78 =head1 VERSION
79  
80 version 0.000008
81  
82 =head1 AUTHOR
83  
84 Olaf Alders <olaf@wundercounter.com>
85  
86 =head1 COPYRIGHT AND LICENSE
87  
88 This software is copyright (c) 2015 by Olaf Alders.
89  
90 This is free software; you can redistribute it and/or modify it under
91 the same terms as the Perl 5 programming language system itself.
92  
93 =cut
94  
95 __END__
96  
97 # ABSTRACT: Pull request statistics for a given repository
« MergeVelocity/Repository.pm ↑ Summary MergeVelocity/Types.pm »