6 use File::Find::Object ();
7 use Path::Tiny qw/ path /;
8 use Test::More tests => 3;
9 use Test::Differences (qw( eq_or_diff ));
11 my $tree = File::Find::Object->new( {}, $ENV{SRC_DIR} );
24 my @trailing_whitespace_results;
26 while ( my $r = $tree->next_obj() )
32 not( $r->basename =~ /\A\..*?\.swp\z/
33 or $r->basename =~ /\.(o|dat|valgrind-log)\z/
35 exists( $do_not_check{ join '/', @{ $r->full_components } } ) )
38 my $contents = path($fn)->slurp_raw;
40 if ( $contents =~ /\r/ )
42 push @cr_results, $fn;
44 elsif ( $contents =~ /[ \t]$/ms )
46 push @trailing_whitespace_results, $fn;
48 elsif ( $r->basename =~ /\.[ch]\z/ and $contents =~ /\t/ )
50 push @tabs_results, $fn;
56 if ( ( $r->dir_components->[-1] // '' ) eq '.git' )
64 eq_or_diff( \@cr_results, [], "Files containing carriage returns." );
67 eq_or_diff( \@trailing_whitespace_results,
68 [], "Files containing trailing whitespace." );
71 eq_or_diff( \@tabs_results, [], "Source files containing tabs." );
75 =head1 COPYRIGHT & LICENSE
77 Copyright 2016 by Shlomi Fish
79 This program is distributed under the MIT (X11) License:
80 L<http://www.opensource.org/licenses/mit-license.php>
82 Permission is hereby granted, free of charge, to any person
83 obtaining a copy of this software and associated documentation
84 files (the "Software"), to deal in the Software without
85 restriction, including without limitation the rights to use,
86 copy, modify, merge, publish, distribute, sublicense, and/or sell
87 copies of the Software, and to permit persons to whom the
88 Software is furnished to do so, subject to the following
91 The above copyright notice and this permission notice shall be
92 included in all copies or substantial portions of the Software.
94 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
95 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
96 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
97 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
98 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
99 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
100 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
101 OTHER DEALINGS IN THE SOFTWARE.