rule

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

BlacklistRule is the default rule for blacklist

View Source
var DefaultRules = []*Rule{
	&WhitelistRule,
	&BlacklistRule,
}

DefaultRules are the default rules always used

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

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) FindAllStringIndex added in v0.1.4

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

func (*Rule) Reason added in v0.1.4

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

Reason returns a human-readable reason for the rule violation

func (*Rule) ReasonWithNote added in v0.1.4

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

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

func (*Rule) String

func (r *Rule) String() string

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 Warn
	SevWarn
	// SevInfo translates to Info
	SevInfo
)

func NewSeverity

func NewSeverity(s string) Severity

NewSeverity turns a string into a Severity

func (*Severity) Colorize added in v0.1.4

func (s *Severity) Colorize() string

func (Severity) String

func (s Severity) String() string

func (*Severity) UnmarshalYAML added in v0.1.4

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