Skip to content

Commit cf9f3b8

Browse files
charsbardaxim
authored andcommitted
added a core metric for non_portable_filenames: bad filenames that are not allowed or portable
1 parent b7141df commit cf9f3b8

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

AUTHORS

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ AUTHORS - Authors of and contributors to Module-CPANTS-Analyse
1616

1717
=item L<Lars Dɪᴇᴄᴋᴏᴡ|https://metacpan.org/author/daxim>
1818

19+
=item L<Kenichi Ishigaki|https://metacpan.org/author/ishigaki>
20+
1921
=back
2022

2123
=head2 Contributors
@@ -28,8 +30,6 @@ AUTHORS - Authors of and contributors to Module-CPANTS-Analyse
2830

2931
=item L<Jérôme Quelin|https://metacpan.org/author/jquelin>
3032

31-
=item L<Kenichi Ishigaki|https://metacpan.org/author/charsbar>
32-
3333
=item L<Mike Doherty|https://metacpan.org/author/mdoherty>
3434

3535
=item L<Reini Urban|https://metacpan.org/author/rurban>

Changes

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

99
=over
1010

11+
=item add metric C<non_portable_filenames>
12+
(L<charsbar|https://metacpan.org/author/ishigaki>)
13+
1114
=item numerous fixes for a smoother operation of www-cpants
1215
(L<charsbar|https://metacpan.org/author/ishigaki>)
1316

lib/Module/CPANTS/Kwalitee/Files.pm

+22
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ sub analyse {
4949
$files{$name}{license} = $license;
5050
}
5151
}
52+
53+
# Some characters are not allowed or have special meanings
54+
# under some environment thus should be avoided.
55+
# Filenames that are not allowed under *nix can't be trapped
56+
# here now as they are not extracted at all.
57+
if ($name =~ /[\*\?"<>\|:[:^ascii:]]/) {
58+
push @{$me->d->{non_portable_filenames} ||= []}, $name;
59+
}
5260
}
5361

5462
if (%licenses) {
@@ -309,6 +317,16 @@ sub kwalitee_indicators {
309317
return 1;
310318
},
311319
},
320+
{
321+
name=>'non_portable_filenames',
322+
error=>qq{This distribution has at least one file with non-portable characters in its filename, which may cause problems under some environment},
323+
remedy=>q{Rename those files with alphanumerical characters, or maybe remove them because in many cases they are automatically generated for local installation.},
324+
code=>sub {
325+
my $d=shift;
326+
return 0 if $d->{non_portable_filenames};
327+
return 1;
328+
},
329+
},
312330
];
313331
}
314332

@@ -387,6 +405,10 @@ Returns the Kwalitee Indicators datastructure.
387405
388406
=item * no_stdin_for_prompting
389407
408+
=item * no_large_files
409+
410+
=item * non_portable_filenames
411+
390412
=back
391413
392414
=head1 SEE ALSO

t/02_kwalitee.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Test::NoWarnings;
44

55
use Module::CPANTS::Kwalitee;
66

7-
my $CORE = 25;
7+
my $CORE = 26;
88
my $OPTIONAL = 10; #is_extra set
99
my $EXTRA = 15; #experimental?
1010
my $METRICS = $CORE + $OPTIONAL + $EXTRA;

0 commit comments

Comments
 (0)