Skip to content

Commit fc978e0

Browse files
refactor: rename Rule Type constants
* rename ErrorType to SeverityError * rename WarnType to SeverityWarn
1 parent 0ee7ce1 commit fc978e0

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package commitlint
22

33
// Rule Type Constants
44
const (
5-
WarnType = "warn"
6-
ErrorType = "error"
5+
SeverityWarn = "warn"
6+
SeverityError = "error"
77
)
88

99
// Config represent the rules for commit message

default.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package commitlint
22

33
var defConf = &Config{
44
Header: Header{
5-
MinLength: IntConf{Enabled: true, Type: ErrorType, Value: 10},
6-
MaxLength: IntConf{Enabled: true, Type: ErrorType, Value: 50},
5+
MinLength: IntConf{Enabled: true, Type: SeverityError, Value: 10},
6+
MaxLength: IntConf{Enabled: true, Type: SeverityError, Value: 50},
77
Scopes: EnumConf{
88
Enabled: false,
9-
Type: ErrorType,
9+
Type: SeverityError,
1010
Value: []string{},
1111
},
1212
Types: EnumConf{
1313
Enabled: true,
14-
Type: ErrorType,
14+
Type: SeverityError,
1515
Value: []string{
1616
"feat",
1717
"fix",
@@ -30,11 +30,11 @@ var defConf = &Config{
3030
},
3131
Body: Body{
3232
CanBeEmpty: true,
33-
MaxLineLength: IntConf{Enabled: true, Type: ErrorType, Value: 72},
33+
MaxLineLength: IntConf{Enabled: true, Type: SeverityError, Value: 72},
3434
},
3535
Footer: Footer{
3636
CanBeEmpty: true,
37-
MaxLineLength: IntConf{Enabled: true, Type: ErrorType, Value: 72},
37+
MaxLineLength: IntConf{Enabled: true, Type: SeverityError, Value: 72},
3838
},
3939
}
4040

linter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (l *Linter) Lint(commitMsg string) (lintReport string, hasError bool, err e
2525
if parser.IsHeaderErr(err) {
2626
res := NewResult()
2727
// TODO: show more information
28-
res.add(ErrorType, "commit header is not valid")
28+
res.add(SeverityError, "commit header is not valid")
2929
return l.formReport(msg, res), true, nil
3030
}
3131
return "", false, err
@@ -106,7 +106,7 @@ func (l *Linter) checkBody(msg *parser.Commit, res *Result) {
106106

107107
if !bodyConf.CanBeEmpty {
108108
if msg.Body == "" {
109-
res.add(ErrorType, "body: cannot be empty")
109+
res.add(SeverityError, "body: cannot be empty")
110110
return
111111
}
112112
}
@@ -130,7 +130,7 @@ func (l *Linter) checkFooter(msg *parser.Commit, res *Result) {
130130

131131
if !footConf.CanBeEmpty {
132132
if foot.FullFooter == "" {
133-
res.add(ErrorType, "footer: cannot be empty")
133+
res.add(SeverityError, "footer: cannot be empty")
134134
return
135135
}
136136
}

result.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ type Result struct {
1212
func NewResult() *Result { return &Result{} }
1313

1414
func (res *Result) add(typ, msg string) {
15-
if typ == WarnType {
15+
if typ == SeverityWarn {
1616
res.warns = append(res.warns, msg)
17-
} else if typ == ErrorType {
17+
} else if typ == SeverityError {
1818
res.errs = append(res.errs, msg)
1919
} else {
2020
// default considered as error

0 commit comments

Comments
 (0)