Documentation
¶
Overview ¶
Package ignore holds the parts of the ignore grammar (docs/schema/ignore.v1.md) that both the config resolver and the suppress stage need: rule validation and the forward-slash glob matcher. It imports only the standard library and model.
Index ¶
Constants ¶
const ( MsgEmpty = "value is empty" MsgBadID = "id must be th_ followed by 16 lowercase hex characters" MsgBadDetector = "detector id must not contain whitespace" MsgBadLine = "line must be a positive decimal integer" MsgAbsolute = "path must be relative" MsgParent = "path must not contain a .. segment" MsgBadGlob = "invalid glob" MsgBadKind = "unknown rule kind" MsgBadScope = "unknown rule scope" MsgBadMachine = "machine path must start with ~/" MsgBackslash = "path must use forward slashes" MsgBadSegment = "path must not contain empty or . segments" )
Validation messages. They never contain the rule value.
Variables ¶
var ( ErrEmpty = errors.New(MsgEmpty) ErrBadID = errors.New(MsgBadID) ErrBadDetector = errors.New(MsgBadDetector) ErrBadLine = errors.New(MsgBadLine) ErrAbsolute = errors.New(MsgAbsolute) ErrParent = errors.New(MsgParent) ErrBadGlob = errors.New(MsgBadGlob) ErrBadKind = errors.New(MsgBadKind) ErrBadScope = errors.New(MsgBadScope) ErrBadMachine = errors.New(MsgBadMachine) ErrBackslash = errors.New(MsgBackslash) ErrBadSegment = errors.New(MsgBadSegment) )
Validation errors.
Functions ¶
func Check ¶
func Check(r model.IgnoreRule) error
Check validates a rule built by a parser or a library caller.
func CheckPath ¶
CheckPath checks the forward-slash path or glob p of a path or loc rule: not empty, relative (no leading "/" and no drive letter), no ".." segment, and (for a glob) every segment a valid path.Match pattern. A backslash is rejected: on every OS patterns use forward slashes, and a backslash would be read as a glob escape.
Types ¶
type Glob ¶
type Glob struct {
// contains filtered or unexported fields
}
Glob is a compiled forward-slash glob: "**" is zero or more segments, other segments are path.Match patterns. Matching is case-sensitive on every OS.