Skip to content

Commit 753c8c9

Browse files
charsbardaxim
authored andcommitted
new metric: no_dot_underscore_files (tweaked version of RT#40898, as other ._ files are also problematic, especially for Module::Pluggable and others)
https://rt.cpan.org/Ticket/Display.html?id=40898
1 parent fcad8c9 commit 753c8c9

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

Changes

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Changes - Revision history for Module-CPANTS-Analyse
88

99
=over
1010

11+
=item add metric C<no_dot_underscore_files>
12+
(L<daxim|https://metacpan.org/author/daxim>,
13+
L<charsbar|https://metacpan.org/author/ishigaki>)
14+
1115
=item remove metrics C<distributed_by_debian>,
1216
C<latest_version_distributed_by_debian>, C<has_no_bugs_reported_in_debian>,
1317
C<has_no_patches_in_debian>, C<no_cpants_errors>, C<uses_test_nowarnings>,

lib/Module/CPANTS/Kwalitee/Files.pm

+18
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ sub analyse {
3434
my $size = 0;
3535
my %files;
3636
my %licenses;
37+
my @dot_underscore_files;
3738
foreach my $name (@files) {
3839
my $path = catfile($distdir, $name);
3940
$files{$name}{size} += -s $path || 0;
@@ -56,6 +57,10 @@ sub analyse {
5657
if ($name =~ /[\*\?"<>\|:[:^ascii:]]/) {
5758
push @{$me->d->{non_portable_filenames} ||= []}, $name;
5859
}
60+
61+
if ($name =~ m!(^|/)\._!) {
62+
push @dot_underscore_files, $name;
63+
}
5964
}
6065

6166
if (%licenses) {
@@ -90,6 +95,7 @@ sub analyse {
9095
$me->d->{dirs_array}=\@dirs;
9196
$me->d->{symlinks}=scalar @symlinks;
9297
$me->d->{symlinks_list}=join(';',@symlinks);
98+
$me->d->{error}{no_dot_underscore_files} = \@dot_underscore_files if @dot_underscore_files;
9399

94100
# find special files
95101
my %reqfiles;
@@ -324,6 +330,16 @@ sub kwalitee_indicators {
324330
return 1;
325331
},
326332
},
333+
{
334+
name=>'no_dot_underscore_files',
335+
error=>qq{This distribution has dot underscore files which may cause various problems.},
336+
remedy=>q{If you use Mac OS X, set COPYFILE_DISABLE (for OS 10.5 and better) or COPY_EXTENDED_ATTRIBUTES_DISABLE (for OS 10.4) environmental variable to true to exclude dot underscore files from a distribution.},
337+
code=>sub {
338+
my $d=shift;
339+
return 0 if $d->{error}{no_dot_underscore_files};
340+
return 1;
341+
},
342+
},
327343
];
328344
}
329345

@@ -406,6 +422,8 @@ Returns the Kwalitee Indicators datastructure.
406422
407423
=item * non_portable_filenames
408424
425+
=item * no_dot_underscore_files
426+
409427
=back
410428
411429
=head1 SEE ALSO

t/02_kwalitee.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use Test::NoWarnings;
77
use Module::CPANTS::Kwalitee;
88

99
my $CORE = 26;
10-
my $OPTIONAL = 10; #is_extra set
11-
my $EXTRA = 15; #experimental?
10+
my $OPTIONAL = 8; #is_extra set
11+
my $EXTRA = 10; #experimental?
1212
my $METRICS = $CORE + $OPTIONAL + $EXTRA;
1313

1414
plan tests => 8 + 2 * $METRICS;

0 commit comments

Comments
 (0)