line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Lint::Check::Message; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2886
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
106
|
|
4
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
106
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
17
|
use parent 'Git::Lint::Check'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
1517
|
use Git::Lint::Command; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
1381
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.016'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub message { |
13
|
3
|
|
|
3
|
1
|
987
|
my $self = shift; |
14
|
3
|
|
|
|
|
10
|
my $args = { |
15
|
|
|
|
|
|
|
file => undef, |
16
|
|
|
|
|
|
|
@_, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
6
|
foreach ( keys %{$args} ) { |
|
3
|
|
|
|
|
9
|
|
20
|
|
|
|
|
|
|
die "$_ is a required argument" |
21
|
3
|
100
|
|
|
|
34
|
unless defined $args->{$_}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
7
|
my $lines_arref = []; |
25
|
|
|
|
|
|
|
open( my $message_fh, '<', $args->{file} ) |
26
|
2
|
100
|
|
|
|
166
|
or die 'open: ' . $args->{file} . ': ' . $!; |
27
|
1
|
|
|
|
|
46
|
while ( my $line = <$message_fh> ) { |
28
|
3
|
|
|
|
|
7
|
chomp $line; |
29
|
3
|
|
|
|
|
4
|
push @{$lines_arref}, $line; |
|
3
|
|
|
|
|
16
|
|
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
|
|
13
|
close($message_fh); |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
4
|
unless ($lines_arref) { |
34
|
0
|
|
|
|
|
0
|
exit 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
7
|
return $lines_arref; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub format_issue { |
41
|
3
|
|
|
3
|
1
|
53
|
my $self = shift; |
42
|
3
|
|
|
|
|
9
|
my $args = { |
43
|
|
|
|
|
|
|
check => undef, |
44
|
|
|
|
|
|
|
@_, |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
5
|
foreach ( keys %{$args} ) { |
|
3
|
|
|
|
|
9
|
|
48
|
|
|
|
|
|
|
die "$_ is a required argument" |
49
|
3
|
100
|
|
|
|
16
|
unless defined $args->{$_}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
4
|
my $message = $args->{check}; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
7
|
return { message => $message }; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub parse { |
58
|
5
|
|
|
5
|
1
|
164
|
my $self = shift; |
59
|
5
|
|
|
|
|
21
|
my $args = { |
60
|
|
|
|
|
|
|
input => undef, |
61
|
|
|
|
|
|
|
match => undef, |
62
|
|
|
|
|
|
|
check => undef, |
63
|
|
|
|
|
|
|
@_, |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
10
|
foreach ( keys %{$args} ) { |
|
5
|
|
|
|
|
16
|
|
67
|
|
|
|
|
|
|
die "$_ is a required argument" |
68
|
11
|
100
|
|
|
|
57
|
unless defined $args->{$_}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
die 'match argument must be a code ref' |
72
|
2
|
100
|
|
|
|
16
|
unless ref $args->{match} eq 'CODE'; |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
2
|
my @issues; |
75
|
1
|
50
|
|
|
|
3
|
if ( $args->{match}->( $args->{input} ) ) { |
76
|
1
|
|
|
|
|
16
|
push @issues, $self->format_issue( check => $args->{check}, ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
4
|
return @issues; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |