distrolint/Check/HardTabs.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 40 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 # You may distribute under the terms of either the GNU General Public License
2 # or the Artistic License (the same terms as Perl itself)
3 #
4 # (C) Paul Evans, 2023 -- leonerd@leonerd.org.uk
5  
6 use v5.36;
7 use Object::Pad 0.807;
8  
9 class App::perl::distrolint::Check::HardTabs 0.09;
10  
11 apply App::perl::distrolint::CheckRole::EachFile;
12  
13 use constant DESC => "check that no source code file contains HT characters";
14 use constant SORT => 8;
15  
16 use File::Slurper qw( read_lines );
17  
18 =head1 NAME
19  
20 C<App::perl::distrolint::Check::HardTabs> - check that no source file contains HT characters
21  
22 =head1 DESCRIPTION
23  
24 This checks that no source code file contains horizontal tab (HT) characters.
25  
26 It operates on all the files considered to be "source", except that it will
27 ignore any F<.c> file if a corresponding F<.xs> file is also present, as
28 F<xsubpp> is known to generate tab characters in its output, and this would
29 leads to many false positives.
30  
31 =cut
32  
33 method run ( $app )
34 {
35 return $self->run_for_each_source_file( check_file => );
36 }
37  
38 method check_file ( $file )
39 {
40 # Skip any .c file that appears to be generated from a .xs file
41 return 1 if $file =~ m/\.c$/ and -f $file =~ s/\.c$/.xs/r;
42  
43 my @lines = read_lines $file;
44  
45 foreach my $i ( 0 .. $#lines ) {
46 next unless $lines[$i] =~ m/\t/;
47  
48 App->diag( App->format_file( $file, $i+1 ), " contains a \\t character" );
49 return 0;
50 }
51  
52 return 1;
53 }
54  
55 =head1 AUTHOR
56  
57 Paul Evans <leonerd@leonerd.org.uk>
58  
59 =cut
60  
61 0x55AA;