Hack to address circular dependency in rulelist

This commit is contained in:
Grant Murphy 2017-05-09 21:26:12 -07:00
parent 5160048ba6
commit 65b18da711

View file

@ -15,18 +15,24 @@
package rules package rules
import ( import (
"go/ast"
"github.com/GoASTScanner/gas" "github.com/GoASTScanner/gas"
) )
type RuleDefinition struct { type RuleDefinition struct {
Description string Description string
Create func(c gas.Config) (gas.Rule, []ast.Node) Create gas.RuleBuilder
} }
type RuleList map[string]RuleDefinition type RuleList map[string]RuleDefinition
func (rl RuleList) Builders() []gas.RuleBuilder {
builders := make([]gas.RuleBuilder, 0, len(rl))
for _, def := range rl {
builders = append(builders, def.Create)
}
return builders
}
type RuleFilter func(string) bool type RuleFilter func(string) bool
func NewRuleFilter(action bool, ruleIDs ...string) RuleFilter { func NewRuleFilter(action bool, ruleIDs ...string) RuleFilter {