line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Git::Lint::Check::Message; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
3334
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
167
|
|
4
|
5
|
|
|
5
|
|
22
|
use warnings; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
110
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
22
|
use parent 'Git::Lint::Check'; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
33
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
1569
|
use Git::Lint::Command; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
1721
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.015'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub message { |
13
|
3
|
|
|
3
|
1
|
795
|
my $self = shift; |
14
|
3
|
|
|
|
|
7
|
my $args = { |
15
|
|
|
|
|
|
|
file => undef, |
16
|
|
|
|
|
|
|
@_, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
5
|
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
|
|
|
|
115
|
or die 'open: ' . $args->{file} . ': ' . $!; |
27
|
1
|
|
|
|
|
39
|
while ( my $line = <$message_fh> ) { |
28
|
3
|
|
|
|
|
5
|
chomp $line; |
29
|
3
|
|
|
|
|
4
|
push @{$lines_arref}, $line; |
|
3
|
|
|
|
|
15
|
|
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
|
|
9
|
close($message_fh); |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
3
|
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
|
|
|
|
|
4
|
foreach ( keys %{$args} ) { |
|
3
|
|
|
|
|
8
|
|
48
|
|
|
|
|
|
|
die "$_ is a required argument" |
49
|
3
|
100
|
|
|
|
17
|
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
|
139
|
my $self = shift; |
59
|
5
|
|
|
|
|
16
|
my $args = { |
60
|
|
|
|
|
|
|
input => undef, |
61
|
|
|
|
|
|
|
match => undef, |
62
|
|
|
|
|
|
|
check => undef, |
63
|
|
|
|
|
|
|
@_, |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
|
|
6
|
foreach ( keys %{$args} ) { |
|
5
|
|
|
|
|
14
|
|
67
|
|
|
|
|
|
|
die "$_ is a required argument" |
68
|
12
|
100
|
|
|
|
47
|
unless defined $args->{$_}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
die 'match argument must be a code ref' |
72
|
2
|
100
|
|
|
|
13
|
unless ref $args->{match} eq 'CODE'; |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
2
|
my @issues; |
75
|
1
|
50
|
|
|
|
2
|
if ( $args->{match}->( $args->{input} ) ) { |
76
|
1
|
|
|
|
|
13
|
push @issues, $self->format_issue( check => $args->{check}, ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
3
|
return @issues; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |