File: check-perl-critic.pl

package info (click to toggle)
libsvn-hooks-perl 1.19-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 372 kB
  • sloc: perl: 1,443; makefile: 7
file content (25 lines) | stat: -rwxr-xr-x 678 bytes parent folder | download | duplicates (5)
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
# Check if every added/changed Perl file respects Perl::Critic's code
# standards.

PRE_COMMIT {
    my ($svnlook) = @_;
    my %violations;
    my $critic;

    foreach my $file ($svnlook->added(), $svnlook->updated()) {
	next unless $file =~ /\.p[lm]$/i;
	require Perl::Critic;
	$critic ||= Perl::Critic->new(-severity => 'stern', -top => 10);
	my $contents = $svnlook->cat($file);
	my @violations = $critic->critique(\$contents);
	$violations{$file} = \@violations if @violations;
    }

    if (%violations) {
	# FIXME: this is a lame way to format the output.
	require Data::Dumper;
	die "Perl::Critic Violations:\n", Data::Dumper::Dumper(\%violations), "\n";
    }
};

1;