Skip to content

Commit f46b51c

Browse files
refactor!: rename SetAndCheckArgument to Apply
1 parent d25eff3 commit f46b51c

File tree

7 files changed

+42
-40
lines changed

7 files changed

+42
-40
lines changed

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func GetRules(conf *lint.Config) ([]lint.Rule, error) {
119119
return nil, fmt.Errorf("unknown rule: %s", ruleName)
120120
}
121121
if ruleConfig.Enabled {
122-
err := r.SetAndCheckArgument(ruleConfig.Argument)
122+
err := r.Apply(ruleConfig.Argument)
123123
if err != nil {
124124
return nil, err
125125
}

lint/rule.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import "github.com/conventionalcommit/commitlint/message"
66
type Rule interface {
77
// Name returns name of the rule, it should be a unique identifier
88
Name() string
9-
// SetAndCheckArgument sets the argument to the rule from config file
9+
10+
// Apply sets the argument to the rule from config file
1011
// if args are invalid or not expected return an error
11-
// SetAndCheckArgument is called before Validate
12-
SetAndCheckArgument(arg interface{}) error
12+
// Apply is called before Validate
13+
Apply(arg interface{}) error
14+
1315
// Validate validates the rule for given message
1416
Validate(msg *message.Commit) (result string, isValid bool)
1517
}

rule/charset.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ func (r *ScopeCharsetRule) Validate(msg *message.Commit) (string, bool) {
2525
return "", true
2626
}
2727

28-
// SetAndCheckArgument sets the needed argument for the rule
29-
func (r *ScopeCharsetRule) SetAndCheckArgument(arg interface{}) error {
28+
// Apply sets the needed argument for the rule
29+
func (r *ScopeCharsetRule) Apply(arg interface{}) error {
3030
return setStringArg(&r.Charset, arg, r.Name())
3131
}
3232

@@ -48,8 +48,8 @@ func (r *TypeCharsetRule) Validate(msg *message.Commit) (string, bool) {
4848
return "", true
4949
}
5050

51-
// SetAndCheckArgument sets the needed argument for the rule
52-
func (r *TypeCharsetRule) SetAndCheckArgument(arg interface{}) error {
51+
// Apply sets the needed argument for the rule
52+
func (r *TypeCharsetRule) Apply(arg interface{}) error {
5353
return setStringArg(&r.Charset, arg, r.Name())
5454
}
5555

rule/enum.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ func (r *ScopeEnumRule) Validate(msg *message.Commit) (string, bool) {
2525
return "", true
2626
}
2727

28-
// SetAndCheckArgument sets the needed argument for the rule
29-
func (r *ScopeEnumRule) SetAndCheckArgument(arg interface{}) error {
28+
// Apply sets the needed argument for the rule
29+
func (r *ScopeEnumRule) Apply(arg interface{}) error {
3030
err := setStringArrArg(&r.Scopes, arg, r.Name())
3131
if err != nil {
3232
return err
@@ -54,8 +54,8 @@ func (r *TypeEnumRule) Validate(msg *message.Commit) (string, bool) {
5454
return "", true
5555
}
5656

57-
// SetAndCheckArgument sets the needed argument for the rule
58-
func (r *TypeEnumRule) SetAndCheckArgument(arg interface{}) error {
57+
// Apply sets the needed argument for the rule
58+
func (r *TypeEnumRule) Apply(arg interface{}) error {
5959
err := setStringArrArg(&r.Types, arg, r.Name())
6060
if err != nil {
6161
return err

rule/max_length.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func (r *HeadMaxLenRule) Validate(msg *message.Commit) (string, bool) {
1919
return checkMaxLen(r.CheckLen, msg.Header.FullHeader)
2020
}
2121

22-
// SetAndCheckArgument sets the needed argument for the rule
23-
func (r *HeadMaxLenRule) SetAndCheckArgument(arg interface{}) error {
22+
// Apply sets the needed argument for the rule
23+
func (r *HeadMaxLenRule) Apply(arg interface{}) error {
2424
return setIntArg(&r.CheckLen, arg, r.Name())
2525
}
2626

@@ -37,8 +37,8 @@ func (r *BodyMaxLenRule) Validate(msg *message.Commit) (string, bool) {
3737
return checkMaxLen(r.CheckLen, msg.Body)
3838
}
3939

40-
// SetAndCheckArgument sets the needed argument for the rule
41-
func (r *BodyMaxLenRule) SetAndCheckArgument(arg interface{}) error {
40+
// Apply sets the needed argument for the rule
41+
func (r *BodyMaxLenRule) Apply(arg interface{}) error {
4242
return setIntArg(&r.CheckLen, arg, r.Name())
4343
}
4444

@@ -55,8 +55,8 @@ func (r *FooterMaxLenRule) Validate(msg *message.Commit) (string, bool) {
5555
return checkMaxLen(r.CheckLen, msg.Footer.FullFooter)
5656
}
5757

58-
// SetAndCheckArgument sets the needed argument for the rule
59-
func (r *FooterMaxLenRule) SetAndCheckArgument(arg interface{}) error {
58+
// Apply sets the needed argument for the rule
59+
func (r *FooterMaxLenRule) Apply(arg interface{}) error {
6060
return setIntArg(&r.CheckLen, arg, r.Name())
6161
}
6262

@@ -73,8 +73,8 @@ func (r *TypeMaxLenRule) Validate(msg *message.Commit) (string, bool) {
7373
return checkMaxLen(r.CheckLen, msg.Header.Type)
7474
}
7575

76-
// SetAndCheckArgument sets the needed argument for the rule
77-
func (r *TypeMaxLenRule) SetAndCheckArgument(arg interface{}) error {
76+
// Apply sets the needed argument for the rule
77+
func (r *TypeMaxLenRule) Apply(arg interface{}) error {
7878
return setIntArg(&r.CheckLen, arg, r.Name())
7979
}
8080

@@ -91,8 +91,8 @@ func (r *ScopeMaxLenRule) Validate(msg *message.Commit) (string, bool) {
9191
return checkMaxLen(r.CheckLen, msg.Header.Scope)
9292
}
9393

94-
// SetAndCheckArgument sets the needed argument for the rule
95-
func (r *ScopeMaxLenRule) SetAndCheckArgument(arg interface{}) error {
94+
// Apply sets the needed argument for the rule
95+
func (r *ScopeMaxLenRule) Apply(arg interface{}) error {
9696
return setIntArg(&r.CheckLen, arg, r.Name())
9797
}
9898

@@ -109,8 +109,8 @@ func (r *DescriptionMaxLenRule) Validate(msg *message.Commit) (string, bool) {
109109
return checkMaxLen(r.CheckLen, msg.Header.Description)
110110
}
111111

112-
// SetAndCheckArgument sets the needed argument for the rule
113-
func (r *DescriptionMaxLenRule) SetAndCheckArgument(arg interface{}) error {
112+
// Apply sets the needed argument for the rule
113+
func (r *DescriptionMaxLenRule) Apply(arg interface{}) error {
114114
return setIntArg(&r.CheckLen, arg, r.Name())
115115
}
116116

rule/max_line_length.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func (r *BodyMaxLineLenRule) Validate(msg *message.Commit) (string, bool) {
2020
return checkMaxLineLength(r.CheckLen, msg.Body)
2121
}
2222

23-
// SetAndCheckArgument sets the needed argument for the rule
24-
func (r *BodyMaxLineLenRule) SetAndCheckArgument(arg interface{}) error {
23+
// Apply sets the needed argument for the rule
24+
func (r *BodyMaxLineLenRule) Apply(arg interface{}) error {
2525
return setIntArg(&r.CheckLen, arg, r.Name())
2626
}
2727

@@ -38,8 +38,8 @@ func (r *FooterMaxLineLenRule) Validate(msg *message.Commit) (string, bool) {
3838
return checkMaxLineLength(r.CheckLen, msg.Footer.FullFooter)
3939
}
4040

41-
// SetAndCheckArgument sets the needed argument for the rule
42-
func (r *FooterMaxLineLenRule) SetAndCheckArgument(arg interface{}) error {
41+
// Apply sets the needed argument for the rule
42+
func (r *FooterMaxLineLenRule) Apply(arg interface{}) error {
4343
return setIntArg(&r.CheckLen, arg, r.Name())
4444
}
4545

rule/min_length.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ func (r *HeadMinLenRule) Validate(msg *message.Commit) (string, bool) {
1919
return checkMinLen(r.CheckLen, msg.Header.FullHeader)
2020
}
2121

22-
// SetAndCheckArgument sets the needed argument for the rule
23-
func (r *HeadMinLenRule) SetAndCheckArgument(arg interface{}) error {
22+
// Apply sets the needed argument for the rule
23+
func (r *HeadMinLenRule) Apply(arg interface{}) error {
2424
return setIntArg(&r.CheckLen, arg, r.Name())
2525
}
2626

@@ -37,8 +37,8 @@ func (r *BodyMinLenRule) Validate(msg *message.Commit) (string, bool) {
3737
return checkMinLen(r.CheckLen, msg.Body)
3838
}
3939

40-
// SetAndCheckArgument sets the needed argument for the rule
41-
func (r *BodyMinLenRule) SetAndCheckArgument(arg interface{}) error {
40+
// Apply sets the needed argument for the rule
41+
func (r *BodyMinLenRule) Apply(arg interface{}) error {
4242
return setIntArg(&r.CheckLen, arg, r.Name())
4343
}
4444

@@ -55,8 +55,8 @@ func (r *FooterMinLenRule) Validate(msg *message.Commit) (string, bool) {
5555
return checkMinLen(r.CheckLen, msg.Footer.FullFooter)
5656
}
5757

58-
// SetAndCheckArgument sets the needed argument for the rule
59-
func (r *FooterMinLenRule) SetAndCheckArgument(arg interface{}) error {
58+
// Apply sets the needed argument for the rule
59+
func (r *FooterMinLenRule) Apply(arg interface{}) error {
6060
return setIntArg(&r.CheckLen, arg, r.Name())
6161
}
6262

@@ -73,8 +73,8 @@ func (r *TypeMinLenRule) Validate(msg *message.Commit) (string, bool) {
7373
return checkMinLen(r.CheckLen, msg.Header.Type)
7474
}
7575

76-
// SetAndCheckArgument sets the needed argument for the rule
77-
func (r *TypeMinLenRule) SetAndCheckArgument(arg interface{}) error {
76+
// Apply sets the needed argument for the rule
77+
func (r *TypeMinLenRule) Apply(arg interface{}) error {
7878
return setIntArg(&r.CheckLen, arg, r.Name())
7979
}
8080

@@ -91,8 +91,8 @@ func (r *ScopeMinLenRule) Validate(msg *message.Commit) (string, bool) {
9191
return checkMinLen(r.CheckLen, msg.Header.Scope)
9292
}
9393

94-
// SetAndCheckArgument sets the needed argument for the rule
95-
func (r *ScopeMinLenRule) SetAndCheckArgument(arg interface{}) error {
94+
// Apply sets the needed argument for the rule
95+
func (r *ScopeMinLenRule) Apply(arg interface{}) error {
9696
return setIntArg(&r.CheckLen, arg, r.Name())
9797
}
9898

@@ -109,8 +109,8 @@ func (r *DescriptionMinLenRule) Validate(msg *message.Commit) (string, bool) {
109109
return checkMinLen(r.CheckLen, msg.Header.Description)
110110
}
111111

112-
// SetAndCheckArgument sets the needed argument for the rule
113-
func (r *DescriptionMinLenRule) SetAndCheckArgument(arg interface{}) error {
112+
// Apply sets the needed argument for the rule
113+
func (r *DescriptionMinLenRule) Apply(arg interface{}) error {
114114
return setIntArg(&r.CheckLen, arg, r.Name())
115115
}
116116

0 commit comments

Comments
 (0)