forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathperl-lint.pl
More file actions
executable file
·31 lines (26 loc) · 802 Bytes
/
perl-lint.pl
File metadata and controls
executable file
·31 lines (26 loc) · 802 Bytes
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
package Foo;
1;
#!/usr/bin/env perl
package main;
use strict;
use warnings;
use Perl::Lint;
my $file = shift or die "Usage: $0 file";
my $linter = Perl::Lint->new;
my $violations = $linter->lint($file);
if (my $count = scalar(@{$violations})) {
my @sorted = sort {
$a->{filename} cmp $b->{filename}
} sort { $a->{line} <=> $b->{line} } @{$violations};
for my $violation (@sorted) {
my $description = $violation->{description} || 'a something violation found';
(my $policy = $violation->{policy}) =~ s{\APerl::Lint::Policy::}{};
my $line = $violation->{line} == 0 ? 1 : $violation->{line};
printf "%s:%d: %s\n",
$violation->{filename}, $line, $description;
}
return 1;
} else {
printf "No violations!!\n";
return 0;
}