Last active
January 17, 2017 10:07
-
-
Save moznion/cb02f138e2736acdc15b4ab73e09b6f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| use utf8; | |
| use feature qw/say/; | |
| use File::Find qw/find/; | |
| # usage example: perl mouse_coding_rule_checker.pl lib/ | |
| my $location = shift or die 'Please give location'; | |
| my @files; | |
| find( | |
| sub { push @files, $File::Find::name unless -d; }, | |
| $location | |
| ); | |
| my @invalid_files; | |
| for my $file (@files) { | |
| open my $fh, '<', $file or die "Failed to open file: $!"; | |
| my $lines = do { local $/; <$fh> }; | |
| if ( | |
| $lines =~ /use\s+Mouse/ && | |
| ($lines !~ /no\s+Mouse/ || $lines !~ /__PACKAGE__->meta->make_immutable/) | |
| ) { | |
| push @invalid_files, $file; | |
| } | |
| } | |
| local $, = "\n"; | |
| say q{Following each file doesn't include `no Mouse` and/or `__PACKAGE__->meta->make_immutable` in spite of `use Mouse`}; | |
| say @invalid_files; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment