line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Dashboard::Distribution; |
2
|
|
|
|
|
|
|
$CPAN::Dashboard::Distribution::VERSION = '0.02'; |
3
|
1
|
|
|
1
|
|
18
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
5
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has 'name' => ( is => 'ro' ); |
7
|
|
|
|
|
|
|
has 'modules' => ( is => 'rw' ); |
8
|
|
|
|
|
|
|
has 'release_path' => ( is => 'rw' ); |
9
|
|
|
|
|
|
|
has 'distinfo' => ( is => 'rw' ); |
10
|
|
|
|
|
|
|
has 'version' => ( is => 'rw' ); |
11
|
|
|
|
|
|
|
has 'is_developer' => ( is => 'rw' ); |
12
|
|
|
|
|
|
|
has 'release_date' => ( is => 'rw' ); |
13
|
|
|
|
|
|
|
has 'owner' => ( is => 'rw' ); |
14
|
|
|
|
|
|
|
has 'bug_count' => ( is => 'rw' ); |
15
|
|
|
|
|
|
|
has 'rev_deps_count' => ( is => 'rw' ); |
16
|
|
|
|
|
|
|
has 'cpan_testers' => ( is => 'rw' ); |
17
|
|
|
|
|
|
|
has 'kwalitee' => ( is => 'rw' ); |
18
|
|
|
|
|
|
|
has 'rating' => ( is => 'lazy' ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _build_rating |
21
|
|
|
|
|
|
|
{ |
22
|
0
|
|
|
0
|
|
|
my $self = shift; |
23
|
0
|
|
|
|
|
|
my $rating = 0; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
# Do all the negative components first |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
$rating-- if ($self->version =~ /^0\./); |
30
|
0
|
0
|
|
|
|
|
$rating-- if ($self->is_developer); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my @owners = @{ $self->owner }; |
|
0
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
if (@owners == 1) { |
34
|
|
|
|
|
|
|
# no owners (only co-maint(s) |
35
|
0
|
0
|
|
|
|
|
$rating-- if $owners[0] eq '__undef'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
else { |
38
|
|
|
|
|
|
|
# more than one owner |
39
|
0
|
|
|
|
|
|
$rating--; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$rating-- if $self->bug_count > 0; |
43
|
0
|
0
|
|
|
|
|
$rating-- if $self->bug_count > 10; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
0
|
|
|
|
if (!defined($self->kwalitee) || $self->kwalitee->core_kwalitee < 100) { |
46
|
0
|
|
|
|
|
|
$rating--; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if (!defined($self->cpan_testers)) { |
50
|
|
|
|
|
|
|
# if we could find a CPAN Testers, it means either the site |
51
|
|
|
|
|
|
|
# was down, so it's a new module. |
52
|
|
|
|
|
|
|
# Seems fair to assume the worst :-) |
53
|
0
|
|
|
|
|
|
$rating--; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
|
|
|
|
|
my $testers = $self->cpan_testers; |
57
|
0
|
|
|
|
|
|
my $total = $testers->passes + $testers->fails + $testers->unknowns; |
58
|
0
|
0
|
|
|
|
|
my $score = $total > 0 ? $testers->passes / $total : 0; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
0
|
|
|
|
if ($total < 100 || ($score < 0.95 && $score > 0.5)) { |
|
|
0
|
0
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$rating--; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif ($score < 0.5) { |
64
|
0
|
|
|
|
|
|
$rating -= 2; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# You can only go positive if you didn't have any negative components |
70
|
|
|
|
|
|
|
# |
71
|
0
|
0
|
|
|
|
|
if ($rating < 0) { |
72
|
0
|
|
|
|
|
|
return $rating; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
$rating++ if $self->bug_count == 0; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# TODO: should only get +1 if the dependent dist isn't also yours |
78
|
0
|
0
|
|
|
|
|
$rating++ if $self->rev_deps_count > 1; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
$rating++ if $self->kwalitee->kwalitee >= 130; |
81
|
0
|
0
|
0
|
|
|
|
$rating++ if $self->cpan_testers->fails == 0 |
82
|
|
|
|
|
|
|
&& $self->cpan_testers->unknowns == 0; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
return $rating; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
CPAN::Dashboard::Distribution - Package to manage the distribution for CPAN Dashboard. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
B |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 REPOSITORY |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Neil Bowers Eneilb@cpan.orgE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Neil Bowers . |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
110
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |