Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileMatcherFunc ¶
FileMatcherFunc describes a function that checks whether a file is relevant to a rule.
func AndMatcher ¶
func AndMatcher(fm ...FileMatcherFunc) FileMatcherFunc
AndMatcher returns true when all match the file.
func OrMatcher ¶
func OrMatcher(fm ...FileMatcherFunc) FileMatcherFunc
OrMatcher returns true when any match the file.
func ShellMatch ¶
func ShellMatch(pattern string) FileMatcherFunc
ShellMatch uses standard shell syntax. E.g "**/*.go" matches all Go files.
type FileReference ¶
type FileReference struct { Name string // Pos, End are byte indices when specifying a problem within the file. Pos, End int }
FileReference describes a chunk of a file.
type ReportFunc ¶
type ReportFunc func(reference FileReference, message string)
ReportFunc describes a function used to report lint violations.
type Rule ¶
type Rule struct { Name string // Linter runs when all matched files have been loaded. // Linter runs all at once so that cross-codebase checks can be performed. // Validators should not return an error for lint violations. Linter ValidatorFunc }
A Rule defines a lint rule. The engine first assue
type RuleSet ¶
type RuleSet []Rule
RuleSet describes a set of rules loaded at linttime.
func (*RuleSet) Add ¶
func (rs *RuleSet) Add(name string, lint ValidatorFunc)
Add adds a new rule to the RuleSet.
type Runner ¶
type Runner struct { Matcher string DebugLogger *flog.Logger Log *flog.Logger // contains filtered or unexported fields }
Runner runs the RuleSet.
type SingleValidator ¶
type SingleValidator func(f FileInfo, report ReportFunc) error
SingleValidator a ValidatorFunc for rules that do not perform cross-file checks. SingleValidator populates FileReference.Name in the report automatically.
type ValidatorFunc ¶
type ValidatorFunc func(files map[string]FileInfo, report ReportFunc) error