line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::CPANTS::Kwalitee::Manifest; |
2
|
7
|
|
|
7
|
|
4229
|
use warnings; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
290
|
|
3
|
7
|
|
|
7
|
|
44
|
use strict; |
|
7
|
|
|
|
|
28
|
|
|
7
|
|
|
|
|
194
|
|
4
|
7
|
|
|
7
|
|
56
|
use File::Spec::Functions qw(catfile); |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
316
|
|
5
|
7
|
|
|
7
|
|
3307
|
use Array::Diff; |
|
7
|
|
|
|
|
91856
|
|
|
7
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
8
|
|
|
|
|
|
|
$VERSION =~ s/_//; ## no critic |
9
|
|
|
|
|
|
|
|
10
|
56
|
|
|
56
|
1
|
124
|
sub order { 100 } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
################################################################## |
13
|
|
|
|
|
|
|
# Analyse |
14
|
|
|
|
|
|
|
################################################################## |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub analyse { |
17
|
11
|
|
|
11
|
1
|
51
|
my $class = shift; |
18
|
11
|
|
|
|
|
28
|
my $me = shift; |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
|
|
287
|
my $distdir = $me->distdir; |
21
|
11
|
|
|
|
|
145
|
my $manifest_file = catfile($distdir, 'MANIFEST'); |
22
|
|
|
|
|
|
|
|
23
|
11
|
100
|
|
|
|
206
|
if (-e $manifest_file) { |
24
|
|
|
|
|
|
|
# read manifest |
25
|
4
|
50
|
|
|
|
174
|
open(my $fh, '<', $manifest_file) or die "cannot read MANIFEST $manifest_file: $!"; |
26
|
4
|
|
|
|
|
18
|
my %seen; |
27
|
4
|
|
|
|
|
64
|
while (<$fh>) { |
28
|
7
|
|
|
|
|
19
|
chomp; |
29
|
7
|
50
|
|
|
|
22
|
next if /^\s*#/; # discard pure comments |
30
|
7
|
50
|
|
|
|
22
|
if (s/^'(\\[\\']|.+)+'\s*.*/$1/) { |
31
|
0
|
|
|
|
|
0
|
s/\\([\\'])/$1/g; |
32
|
|
|
|
|
|
|
} else { |
33
|
7
|
|
|
|
|
19
|
s/\s.*$//; |
34
|
|
|
|
|
|
|
} # strip quotes and comments |
35
|
7
|
50
|
|
|
|
15
|
next unless $_; # discard blank lines |
36
|
7
|
|
|
|
|
65
|
$seen{$_}++; |
37
|
|
|
|
|
|
|
} |
38
|
4
|
|
|
|
|
40
|
close $fh; |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
44
|
my @manifest = sort keys %seen; |
41
|
4
|
50
|
|
|
|
13
|
my @files = sort keys %{$me->d->{files_hash} || {}}; |
|
4
|
|
|
|
|
168
|
|
42
|
4
|
|
|
|
|
62
|
my @dupes = grep {$seen{$_} > 1} @manifest; |
|
7
|
|
|
|
|
23
|
|
43
|
|
|
|
|
|
|
|
44
|
4
|
|
|
|
|
72
|
my $diff = Array::Diff->diff(\@manifest, \@files); |
45
|
4
|
100
|
66
|
|
|
2584
|
if ($diff->count == 0 && !@dupes) { |
46
|
1
|
|
|
|
|
26
|
$me->d->{manifest_matches_dist} = 1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
3
|
|
|
|
|
256
|
$me->d->{manifest_matches_dist} = 0; |
50
|
3
|
|
|
|
|
74
|
my @error = ( |
51
|
|
|
|
|
|
|
'MANIFEST ('.(@manifest + @dupes).') does not match dist ('.@files."):", |
52
|
|
|
|
|
|
|
); |
53
|
3
|
50
|
|
|
|
18
|
if (my @added = @{$diff->added}) { |
|
3
|
|
|
|
|
114
|
|
54
|
3
|
|
|
|
|
52
|
push @error, "Missing in MANIFEST: ".join(', ', @added); |
55
|
|
|
|
|
|
|
} |
56
|
3
|
100
|
|
|
|
12
|
if (my @deleted = @{$diff->deleted}) { |
|
3
|
|
|
|
|
85
|
|
57
|
1
|
|
|
|
|
22
|
push @error, "Missing in Dist: " . join(', ', @deleted); |
58
|
|
|
|
|
|
|
} |
59
|
3
|
50
|
|
|
|
33
|
if (@dupes) { |
60
|
0
|
|
|
|
|
0
|
push @error, "Duplicates in MANIFEST: " . join(', ', @dupes); |
61
|
|
|
|
|
|
|
} |
62
|
3
|
|
|
|
|
67
|
$me->d->{error}{manifest_matches_dist} = \@error; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Tweak symlinks error for a local distribution (RT #97858) |
66
|
4
|
100
|
100
|
|
|
95
|
if ($me->d->{is_local_distribution} && $me->d->{error}{symlinks}) { |
67
|
1
|
|
|
|
|
49
|
my %manifested = map {$_ => 1} @manifest; |
|
1
|
|
|
|
|
11
|
|
68
|
1
|
|
|
|
|
35
|
my @symlinks = grep {$manifested{$_}} split ',', $me->d->{error}{symlinks}; |
|
1
|
|
|
|
|
11
|
|
69
|
1
|
50
|
|
|
|
19
|
if (@symlinks) { |
70
|
0
|
|
|
|
|
0
|
$me->d->{error}{symlinks} = join ',', @symlinks; |
71
|
|
|
|
|
|
|
} else { |
72
|
1
|
|
|
|
|
31
|
delete $me->d->{error}{symlinks}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
7
|
|
|
|
|
186
|
$me->d->{manifest_matches_dist} = 0; |
78
|
7
|
|
|
|
|
210
|
$me->d->{error}{manifest_matches_dist} = q{Cannot find MANIFEST in dist.}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
################################################################## |
83
|
|
|
|
|
|
|
# Kwalitee Indicators |
84
|
|
|
|
|
|
|
################################################################## |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub kwalitee_indicators { |
87
|
|
|
|
|
|
|
return [ |
88
|
|
|
|
|
|
|
{ |
89
|
|
|
|
|
|
|
name => 'manifest_matches_dist', |
90
|
|
|
|
|
|
|
error => q{MANIFEST does not match the contents of this distribution.}, |
91
|
|
|
|
|
|
|
remedy => q{Run a proper command ("make manifest" or "./Build manifest", maybe with a force option), or use a distribution builder to generate the MANIFEST. Or update MANIFEST manually.}, |
92
|
11
|
100
|
|
11
|
|
123
|
code => sub { shift->{manifest_matches_dist} ? 1 : 0 }, |
93
|
|
|
|
|
|
|
details => sub { |
94
|
0
|
|
|
0
|
|
0
|
my $d = shift; |
95
|
0
|
|
|
|
|
0
|
my $error = $d->{error}{manifest_matches_dist}; |
96
|
0
|
0
|
|
|
|
0
|
return $error unless ref $error; |
97
|
0
|
|
|
|
|
0
|
return join "\n", @$error; |
98
|
|
|
|
|
|
|
}, |
99
|
|
|
|
|
|
|
} |
100
|
8
|
|
|
8
|
1
|
108
|
]; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
q{Listening to: YAPC::Europe 2007}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |