File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -29,20 +29,30 @@ func (l *Linter) LintCommit(msg *Commit) (*Result, error) {
29
29
res := newResult (msg .FullCommit )
30
30
31
31
for _ , rule := range l .rules {
32
- result , isOK := rule .Validate (msg )
33
- if ! isOK {
34
- ruleConf := l .conf .GetRule (rule .Name ())
35
- res .add (RuleResult {
36
- Name : rule .Name (),
37
- Severity : ruleConf .Severity ,
38
- Message : result ,
39
- })
32
+ currentRule := rule
33
+ ruleConf := l .conf .GetRule (currentRule .Name ())
34
+ ruleRes , isValid := l .runRule (currentRule , ruleConf .Severity , msg )
35
+ if ! isValid {
36
+ res .add (ruleRes )
40
37
}
41
38
}
42
39
43
40
return res , nil
44
41
}
45
42
43
+ func (l * Linter ) runRule (rule Rule , severity Severity , msg * Commit ) (RuleResult , bool ) {
44
+ ruleMsg , isOK := rule .Validate (msg )
45
+ if isOK {
46
+ return RuleResult {}, true
47
+ }
48
+ res := RuleResult {
49
+ Name : rule .Name (),
50
+ Severity : severity ,
51
+ Message : ruleMsg ,
52
+ }
53
+ return res , false
54
+ }
55
+
46
56
func (l * Linter ) headerErrorRule (commitMsg string ) * Result {
47
57
// TODO: show more information
48
58
res := newResult (commitMsg )
You can’t perform that action at this time.
0 commit comments