From b2831909c4e2d55b5d498907d62e4af1bc0cda4d Mon Sep 17 00:00:00 2001 From: Matthew Barksdale Date: Sat, 25 Dec 2010 23:17:58 -0500 Subject: [PATCH] Import a Perl::Critic script I made --- scripts/check | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 scripts/check diff --git a/scripts/check b/scripts/check new file mode 100755 index 0000000..8e9f8e3 --- /dev/null +++ b/scripts/check @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +# Copyright 2010 Ethrik development team # +use strict; +use warnings; +use Perl::Critic; +my $level; + +if (!defined $ARGV[0]) +{ + print "usage: $0 [level]\n"; + exit 0; +} + +if (!-e $ARGV[0]) +{ + print "$0: could not find $ARGV[0]\n"; + print "usage: $0 [level]\n"; + exit 0; +} + +if ($ARGV[1] and $ARGV[1] =~ m/(5|4|3|2|1|gentle|stern|harsh|cruel|brutal)/xsm) { + $level = $ARGV[1]; +} +else { + $level = 1; +} + + +my $critic = Perl::Critic->new(-severity => $level); +my @violations = $critic->critique($ARGV[0]); + +if (!defined $violations[0]) +{ + print "$ARGV[0] passed (no violations)\n"; + exit 0; +} + +print "Violations:\n"; +my $count = 0; +print "$_\n" and $count++ foreach (@violations); +print "Errors: $count\n";