1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
use warnings;
use strict;
# Check for comments and POD flagged with FIX.
# Are there any modules that already does this?
# Perl::Critic::Policy::Bangs::ProhibitFlagComments doesn't consider
# POD. Make a Perl::Critic::Policy out of this?
use English qw(-no_match_vars);
use File::Find;
use FindBin;
use Test::More tests => 1;
use Pod::Simple::TextContent;
my $count = 0;
find(\&fixes, "$FindBin::Bin/../lib");
is($count, 0, "Should not find any FIX comments");
sub fixes {
my $file = $File::Find::name;
return unless -f $file;
#
# Check comments
#
open my $F, '<', $file
or warn "Couldn't open $file: $!" && return;
while (<$F>) {
if (m{#\s*FIX}) {
printf "Found a FIX comment at %s: %d\n",
$file, $.;
$count++;
}
}
close $F;
#
# Check POD
#
my $pod_parser = Pod::Simple::TextContent->new;
my $pod = "";
$pod_parser->output_string(\$pod);
$pod_parser->parse_file($file);
my $pod_count = scalar(grep {/FIX/} split /\n/, $pod);
printf "Found %d FIX(es) in POD in %s\n",
$pod_count,$file if $pod_count;
$count += $pod_count;
}
|