Documentation ¶
Index ¶
- Variables
- type Options
- type Rule
- func (r *Rule) CanIgnoreLine(line string) bool
- func (r *Rule) Disabled() bool
- func (r *Rule) FindMatchIndexes(text string) [][]int
- func (r *Rule) MatchString(s string, wordBoundary bool) bool
- func (r *Rule) Reason(violation string) string
- func (r *Rule) ReasonWithNote(violation string) string
- func (r *Rule) SetRegexp()
- type Severity
Constants ¶
This section is empty.
Variables ¶
var BlackboxRule = Rule{ Name: "blackbox", Terms: []string{"black-box", "blackbox", "black box"}, Alternatives: []string{"closed-box"}, Options: Options{ WordBoundary: false, }, }
BlackboxRule is the default rule for "blackbox"
var BlacklistRule = Rule{ Name: "blacklist", Terms: []string{"blacklist", "black-list", "blacklisted", "black-listed"}, Alternatives: []string{"denylist", "blocklist"}, Severity: 1, Options: Options{ WordBoundary: false, }, }
BlacklistRule is the default rule for "blacklist"
var DefaultRules = []*Rule{ &BlackboxRule, &BlacklistRule, &DummyRule, &GrandfatheredRule, &GuysRule, &ManHoursRule, &MasterSlaveRule, &SanityRule, &SlaveRule, &WhiteboxRule, &WhitelistRule, }
DefaultRules are the default rules always used
var DummyRule = Rule{ Name: "dummy", Terms: []string{"dummy"}, Alternatives: []string{"placeholder", "sample"}, Options: Options{ WordBoundary: false, }, }
DummyRule is the default rule for "dummy"
var GrandfatheredRule = Rule{ Name: "grandfathered", Terms: []string{"grandfathered"}, Alternatives: []string{"legacy status"}, Options: Options{ WordBoundary: false, }, }
GrandfatheredRule is the default rule for "grandfathered"
var GuysRule = Rule{ Name: "guys", Terms: []string{"guys"}, Alternatives: []string{"folks", "people", "you all", "y'all", "yinz"}, Options: Options{ WordBoundary: false, }, }
GuysRule is the default rule for "guys"
var ManHoursRule = Rule{ Name: "man-hours", Terms: []string{"man hours", "man-hours"}, Alternatives: []string{"person hours", "engineer hours"}, Options: Options{ WordBoundary: false, }, }
ManHoursRule is the default rule for "man-hours"
var MasterSlaveRule = Rule{ Name: "master-slave", Terms: []string{"master-slave", "master/slave"}, Alternatives: []string{"leader/follower", "primary/replica", "primary/standby"}, Options: Options{ WordBoundary: false, }, }
MasterSlaveRule is the default rule for "master-slave"
var SanityRule = Rule{ Name: "sanity", Terms: []string{"sanity"}, Alternatives: []string{"confidence", "quick check", "coherence check"}, Options: Options{ WordBoundary: false, }, }
SanityRule is the default rule for "sanity"
var SlaveRule = Rule{ Name: "slave", Terms: []string{"slave"}, Alternatives: []string{"follower", "replica", "standby"}, Options: Options{ WordBoundary: false, }, }
SlaveRule is the default rule for "slave"
var WhiteboxRule = Rule{ Name: "whitebox", Terms: []string{"white-box", "whitebox", "white box"}, Alternatives: []string{"open-box"}, Options: Options{ WordBoundary: false, }, }
WhiteboxRule is the default rule for "whitebox"
var WhitelistRule = Rule{ Name: "whitelist", Terms: []string{"whitelist", "white-list", "whitelisted", "white-listed"}, Alternatives: []string{"allowlist"}, Severity: 1, Options: Options{ WordBoundary: false, }, }
WhitelistRule is the default rule for "whitelist"
Functions ¶
This section is empty.
Types ¶
type Options ¶ added in v0.4.0
type Options struct {
WordBoundary bool `yaml:"word_boundary"`
}
Options are options that can be configured and applied on a per-rule basis
type Rule ¶
type Rule struct { Name string `yaml:"name"` Terms []string `yaml:"terms"` Alternatives []string `yaml:"alternatives"` Note string `yaml:"note"` Severity Severity `yaml:"severity"` Options Options `yaml:"options"` // contains filtered or unexported fields }
Rule is a linter rule
func (*Rule) CanIgnoreLine ¶ added in v0.1.4
CanIgnoreLine returns a boolean value if the line contains the ignore directive. For example, if a line has anywhere, wokeignore:rule=whitelist (should be commented out via whatever the language comment syntax is) it will not report that line in violation with the Rule with the name `whitelist` wokeignore:rule=whitelist
func (*Rule) Disabled ¶ added in v0.1.16
Disabled denotes if the rule is disabled If no terms are provided, this essentially disables the rule which is helpful for disabling default rules. Eventually, there should be a better way to disable a default rule, and then, if a rule has no Terms, it falls back to the Name.
func (*Rule) FindMatchIndexes ¶ added in v0.1.14
FindMatchIndexes returns the start and end indexes for all rule violations for the text supplied.
func (*Rule) MatchString ¶ added in v0.1.14
MatchString reports whether the string s contains any match of the regular expression re.
func (*Rule) ReasonWithNote ¶
ReasonWithNote returns a human-readable reason for the rule violation with an additional note, if defined.
type Severity ¶
type Severity int
Severity is a log severity
func (*Severity) MarshalJSON ¶ added in v0.2.0
MarshalJSON to marshal Severity as a string
func (*Severity) UnmarshalYAML ¶
UnmarshalYAML to unmarshal severity string