line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Perl::Lint; |
2
|
2
|
|
|
2
|
|
11788
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
48
|
|
3
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
40
|
|
4
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
2
|
|
|
|
|
617
|
|
|
2
|
|
|
|
|
12
|
|
5
|
2
|
|
|
2
|
|
766
|
use parent qw/Test::Builder::Module/; |
|
2
|
|
|
|
|
463
|
|
|
2
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my @test_more_exports; |
8
|
2
|
|
|
2
|
|
847
|
BEGIN { @test_more_exports = (qw/done_testing/) } |
9
|
2
|
|
|
2
|
|
498
|
use Test::More import => \@test_more_exports; |
|
2
|
|
|
|
|
3251
|
|
|
2
|
|
|
|
|
12
|
|
10
|
2
|
|
|
2
|
|
319
|
use Carp (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
35
|
|
11
|
2
|
|
|
2
|
|
1369
|
use Path::Tiny 0.068 qw/path/; |
|
2
|
|
|
|
|
16440
|
|
|
2
|
|
|
|
|
110
|
|
12
|
2
|
|
|
2
|
|
625
|
use Perl::Lint; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
777
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = "0.25"; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = (@test_more_exports, qw/all_policies_ok/); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub all_policies_ok { |
19
|
1
|
|
|
1
|
1
|
159
|
local $Test::Builder::Level = $Test::Builder::Level + 2; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
2
|
my ($args) = @_; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
33
|
|
|
4
|
my $targets = $args->{targets} // Carp::croak "Targets must not be empty"; |
24
|
1
|
|
|
|
|
2
|
my $ignore_files = $args->{ignore_files}; |
25
|
|
|
|
|
|
|
|
26
|
1
|
50
|
33
|
|
|
9
|
if (defined $targets && ref $targets ne 'ARRAY') { |
27
|
0
|
|
|
|
|
0
|
Carp::croak 'Target directories are must be an array reference'; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
33
|
|
|
5
|
if (defined $ignore_files && ref $ignore_files ne 'ARRAY') { |
31
|
0
|
|
|
|
|
0
|
Carp::croak 'Ignore files are must be an array reference'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $linter = Perl::Lint->new({ |
35
|
|
|
|
|
|
|
ignore => $args->{ignore_policies}, |
36
|
|
|
|
|
|
|
filter => $args->{filter}, |
37
|
1
|
|
|
|
|
33
|
}); |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
2
|
my @paths; |
40
|
1
|
|
|
|
|
3
|
for my $target (@$targets) { |
41
|
1
|
50
|
|
|
|
21
|
if (-d $target) { |
|
|
0
|
|
|
|
|
|
42
|
|
|
|
|
|
|
path($target)->visit(sub { |
43
|
3
|
|
|
3
|
|
319
|
my ($path) = @_; |
44
|
3
|
50
|
|
|
|
7
|
if ($path->is_file) { |
45
|
3
|
|
|
|
|
33
|
my $path_string = $path->stringify; |
46
|
3
|
100
|
|
|
|
8
|
if (!grep {$_ eq $path_string} @$ignore_files) { |
|
3
|
|
|
|
|
12
|
|
47
|
2
|
|
|
|
|
10
|
push @paths, $path_string; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
1
|
|
|
|
|
4
|
}, {recurse => 1}); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
elsif (-f $target) { |
53
|
0
|
0
|
|
|
|
0
|
if (!grep {$_ eq $target} @$ignore_files) { |
|
0
|
|
|
|
|
0
|
|
54
|
0
|
|
|
|
|
0
|
push @paths, $target; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
|
|
|
0
|
Carp::carp "'$target' doesn't exist"; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
1
|
|
|
|
|
52
|
@paths = sort {$a cmp $b} @paths; |
|
1
|
|
|
|
|
3
|
|
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
for my $path_string (@paths) { |
64
|
2
|
|
|
|
|
512
|
my $violations = $linter->lint($path_string); |
65
|
2
|
100
|
|
|
|
6
|
if (scalar @$violations == 0) { |
66
|
1
|
|
|
|
|
5
|
Test::More::pass(__PACKAGE__ . ' for ' . $path_string); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
1
|
|
|
|
|
2
|
my $package = __PACKAGE__; |
70
|
1
|
|
|
|
|
4
|
my $error_msg = <<"..."; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$package found these violations in "$path_string": |
73
|
|
|
|
|
|
|
... |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
3
|
for my $violation (@$violations) { |
76
|
1
|
|
|
|
|
2
|
my $explanation = $violation->{explanation}; |
77
|
1
|
50
|
|
|
|
3
|
if (ref $explanation eq 'ARRAY') { |
78
|
1
|
|
|
|
|
4
|
$explanation = 'See page ' . join(', ', @$explanation) . ' of PBP'; |
79
|
|
|
|
|
|
|
} |
80
|
1
|
|
|
|
|
5
|
$error_msg .= <<"..."; |
81
|
|
|
|
|
|
|
$violation->{description} at line $violation->{line}. $explanation. |
82
|
|
|
|
|
|
|
... |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
1
|
50
|
|
|
|
7
|
Test::More::ok(0, "$package for $path_string") or Test::More::diag($error_msg); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
198
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |