rule

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlacklistRule = Rule{
	Name:         "blacklist",
	Regexp:       regexp.MustCompile(`\b(black-?list)\b`),
	Alternatives: "denylist,blocklist",
}

BlacklistRule is the default rule for whitelist

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

DefaultRules are the default rules in case a config file with rules is not provided

View Source
var WhitelistRule = Rule{
	Name:         "whitelist",
	Regexp:       regexp.MustCompile(`\b(white-?list)\b`),
	Alternatives: "allowlist",
}

WhitelistRule is the default rule for whitelist

Functions

This section is empty.

Types

type Result

type Result struct {
	Rule     *Rule
	Match    string
	Position *token.Position
}

Result contains data about the result of a broken rule

func (*Result) Reason

func (r *Result) Reason() string

Reason outputs the suggested alternatives for this rule

func (*Result) String

func (r *Result) String() string

type Results

type Results struct {
	Results []Result
}

Results contains a list of Result

func (*Results) Add

func (rs *Results) Add(r *Result)

Add adds a single Result object onto the Results stack

func (*Results) Output

func (rs *Results) Output()

Output is the logger output of results

func (*Results) Push

func (rs *Results) Push(r ...Result)

Push pushes a list of Result objects onto the Results stack

func (*Results) String

func (rs *Results) String() string

type Rule

type Rule struct {
	Name         string         // `yaml:"name"`
	Regexp       *regexp.Regexp // `yaml:"regexp"`
	Alternatives string         // `yaml:"alternatives"`
	Severity     Severity
}

Rule is a linter rule

func (*Rule) String

func (r *Rule) String() string

func (*Rule) UnmarshalYAML

func (r *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML to enforce regexp at the unmarshal level

type Severity

type Severity int

Severity is a log severity

const (
	// SevInfo translates to Info
	SevInfo Severity = iota
	// SevWarn translates to Warn
	SevWarn
	// SevError translates to Error
	SevError
)

func NewSeverity

func NewSeverity(s string) Severity

NewSeverity turns a string into a Severity

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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