Skip to content

Commit 0ae9462

Browse files
committed
rename GetConfig to Config to align getter method names in RuleBase
1 parent 85a89db commit 0ae9462

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

rule.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ func (r *RuleBase) SetConfig(cfg *Config) {
9090
r.config = cfg
9191
}
9292

93-
// GetConfig returns the config of the rule
94-
func (r *RuleBase) GetConfig() *Config {
93+
// Config returns the user configuration of actionlint. When no config was set to this rule by SetConfig,
94+
// this method returns nil.
95+
func (r *RuleBase) Config() *Config {
9596
return r.config
9697
}
9798

@@ -103,5 +104,5 @@ type Rule interface {
103104
Description() string
104105
EnableDebug(out io.Writer)
105106
SetConfig(cfg *Config)
106-
GetConfig() *Config
107+
Config() *Config
107108
}

rule_test.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package actionlint
2+
3+
import "testing"
4+
5+
func TestRuleBaseConfig(t *testing.T) {
6+
r := NewRuleBase("", "")
7+
if r.Config() != nil {
8+
t.Error("Config must be nil after creating a rule")
9+
}
10+
want := &Config{}
11+
r.SetConfig(want)
12+
if have := r.Config(); have != want {
13+
t.Errorf("Wanted config %v but got %v", want, have)
14+
}
15+
}

0 commit comments

Comments
 (0)