Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tflint: Make sure RuleNames always return all rules #100

Merged
merged 1 commit into from
Feb 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tflint/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type BuiltinRuleSet struct {
Name string
Version string
Rules []Rule

EnabledRules []Rule
}

// RuleSetName is the name of the ruleset.
Expand Down Expand Up @@ -42,7 +44,7 @@ func (r *BuiltinRuleSet) ApplyConfig(config *Config) error {

// ApplyCommonConfig reflects common configurations regardless of plugins.
func (r *BuiltinRuleSet) ApplyCommonConfig(config *Config) {
rules := []Rule{}
r.EnabledRules = []Rule{}

if config.DisabledByDefault {
log.Printf("[DEBUG] Only mode is enabled. Ignoring default plugin rules")
Expand All @@ -57,15 +59,14 @@ func (r *BuiltinRuleSet) ApplyCommonConfig(config *Config) {
}

if enabled {
rules = append(rules, rule)
r.EnabledRules = append(r.EnabledRules, rule)
}
}
r.Rules = rules
}

// Check runs inspection for each rule by applying Runner.
func (r *BuiltinRuleSet) Check(runner Runner) error {
for _, rule := range r.Rules {
for _, rule := range r.EnabledRules {
if err := rule.Check(runner); err != nil {
return fmt.Errorf("Failed to check `%s` rule: %s", rule.Name(), err)
}
Expand Down