rule

package
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlackboxRule = Rule{
	Name:         "blackbox",
	Terms:        []string{"black-box", "blackbox", "black box"},
	Alternatives: []string{"closed-box"},
}

BlackboxRule is the default rule for "blackbox"

View Source
var BlacklistRule = Rule{
	Name:         "blacklist",
	Terms:        []string{"blacklist", "black-list", "blacklisted", "black-listed"},
	Alternatives: []string{"denylist", "blocklist"},
	Severity:     1,
}

BlacklistRule is the default rule for "blacklist"

DefaultRules are the default rules always used

View Source
var DummyRule = Rule{
	Name:         "dummy",
	Terms:        []string{"dummy"},
	Alternatives: []string{"placeholder", "sample"},
}

DummyRule is the default rule for "dummy"

View Source
var GrandfatheredRule = Rule{
	Name:         "grandfathered",
	Terms:        []string{"grandfathered"},
	Alternatives: []string{"legacy status"},
}

GrandfatheredRule is the default rule for "grandfathered"

View Source
var GuysRule = Rule{
	Name:         "guys",
	Terms:        []string{"guys"},
	Alternatives: []string{"folks", "people", "you all", "y'all", "yinz"},
}

GuysRule is the default rule for "guys"

View Source
var ManHoursRule = Rule{
	Name:         "man-hours",
	Terms:        []string{"man hours", "man-hours"},
	Alternatives: []string{"person hours", "engineer hours"},
}

ManHoursRule is the default rule for "man-hours"

View Source
var MasterSlaveRule = Rule{
	Name:         "master-slave",
	Terms:        []string{"master-slave", "master/slave"},
	Alternatives: []string{"leader/follower", "primary/replica", "primary/standby"},
}

MasterSlaveRule is the default rule for "master-slave"

View Source
var SanityRule = Rule{
	Name:         "sanity",
	Terms:        []string{"sanity"},
	Alternatives: []string{"confidence", "quick check", "coherence check"},
}

SanityRule is the default rule for "sanity"

View Source
var SlaveRule = Rule{
	Name:         "slave",
	Terms:        []string{"slave"},
	Alternatives: []string{"follower", "replica", "standby"},
}

SlaveRule is the default rule for "slave"

View Source
var WhiteboxRule = Rule{
	Name:         "whitebox",
	Terms:        []string{"white-box", "whitebox", "white box"},
	Alternatives: []string{"open-box"},
}

WhiteboxRule is the default rule for "whitebox"

View Source
var WhitelistRule = Rule{
	Name:         "whitelist",
	Terms:        []string{"whitelist", "white-list", "whitelisted", "white-listed"},
	Alternatives: []string{"allowlist"},
	Severity:     1,
}

WhitelistRule is the default rule for "whitelist"

Functions

This section is empty.

Types

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"`
	// contains filtered or unexported fields
}

Rule is a linter rule

func (*Rule) CanIgnoreLine added in v0.1.4

func (r *Rule) CanIgnoreLine(line string) bool

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) FindMatchIndexes added in v0.1.14

func (r *Rule) FindMatchIndexes(text string) [][]int

FindMatchIndexs returns the start and end indexes for all rule violations for the text supplied.

func (*Rule) MatchString added in v0.1.14

func (r *Rule) MatchString(s string, wordBoundary bool) bool

MatchString reports whether the string s contains any match of the regular expression re.

func (*Rule) MatchString2 added in v0.1.14

func (r *Rule) MatchString2(s string, wordBoundary bool) bool

func (*Rule) Reason

func (r *Rule) Reason(violation string) string

Reason returns a human-readable reason for the rule violation

func (*Rule) ReasonWithNote

func (r *Rule) ReasonWithNote(violation string) string

ReasonWithNote returns a human-readable reason for the rule violation with an additional note, if defined.

func (*Rule) SetRegexp added in v0.1.13

func (r *Rule) SetRegexp()

SetRegexp populates the regex for matching this rule

type Severity

type Severity int

Severity is a log severity

const (
	// SevError translates to Error
	// This will be the default severity
	SevError Severity = iota
	// SevWarn translates to Warning
	SevWarn
	// SevInfo translates to Info
	SevInfo
)

func NewSeverity

func NewSeverity(s string) Severity

NewSeverity turns a string into a Severity

func (*Severity) Colorize

func (s *Severity) Colorize() string

func (Severity) String

func (s Severity) String() string

func (*Severity) UnmarshalYAML

func (s *Severity) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML to unmarshal severity string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL