diff --git a/rule.go b/rule.go index 8a84030e7..40d679d8b 100644 --- a/rule.go +++ b/rule.go @@ -90,8 +90,9 @@ func (r *RuleBase) SetConfig(cfg *Config) { r.config = cfg } -// GetConfig returns the config of the rule -func (r *RuleBase) GetConfig() *Config { +// Config returns the config of the rule. When no config was set to this rule by SetConfig, this +// method returns nil. +func (r *RuleBase) Config() *Config { return r.config } @@ -103,5 +104,5 @@ type Rule interface { Description() string EnableDebug(out io.Writer) SetConfig(cfg *Config) - GetConfig() *Config + Config() *Config } diff --git a/rule_test.go b/rule_test.go new file mode 100644 index 000000000..5e0d66684 --- /dev/null +++ b/rule_test.go @@ -0,0 +1,15 @@ +package actionlint + +import "testing" + +func TestRuleBaseConfig(t *testing.T) { + r := NewRuleBase("", "") + if r.Config() != nil { + t.Error("Config must be nil after creating a rule") + } + want := &Config{} + r.SetConfig(want) + if have := r.Config(); have != want { + t.Errorf("Wanted config %v but got %v", want, have) + } +}