Skip to content

Commit

Permalink
rename GetConfig to Config to align getter method names in `RuleB…
Browse files Browse the repository at this point in the history
…ase`
  • Loading branch information
rhysd committed Feb 9, 2024
1 parent 85a89db commit 0ba913c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -103,5 +104,5 @@ type Rule interface {
Description() string
EnableDebug(out io.Writer)
SetConfig(cfg *Config)
GetConfig() *Config
Config() *Config
}
15 changes: 15 additions & 0 deletions rule_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 0ba913c

Please sign in to comment.