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