ignore

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(comment string) (ruleIDs []string, ok bool)

Parse parses a comment token value into rule IDs. It trims leading/trailing whitespace, then checks if the result starts with "ghasec-ignore". Returns (nil, false) if the comment is not a directive. Returns (nil, true) for all-rules ignore, ([]string, true) for specific rules.

Types

type Directive

type Directive struct {
	Token   *token.Token // The comment token itself
	Line    int          // Target line number (the line being suppressed)
	RuleIDs []string     // Empty means all rules
	// UsedIDs tracks which specific rule IDs have been used (suppressed a diagnostic
	// or flagged as required-rule). For all-rules directives (empty RuleIDs),
	// any entry means the directive was used.
	UsedIDs map[string]bool
}

Directive represents a parsed ghasec-ignore comment.

func Collect

func Collect(tk *token.Token) []*Directive

Collect walks the token chain from tk forward and returns all ignore directives. tk should be the first token in the chain (walk backward from any token to find it).

func (*Directive) IsFullyUsed

func (d *Directive) IsFullyUsed() bool

IsFullyUsed reports whether the entire directive has been used. For all-rules directives, any usage counts. For specific-rule directives, all rule IDs must be used.

func (*Directive) IsUsed

func (d *Directive) IsUsed(ruleID string) bool

IsUsed reports whether the directive (or a specific rule ID) has been used.

func (*Directive) KeywordToken

func (d *Directive) KeywordToken() *token.Token

KeywordToken returns a synthetic token pointing to the "ghasec-ignore" keyword within the comment. Used for diagnostic positioning on all-rules directives.

func (*Directive) MarkUsed

func (d *Directive) MarkUsed(ruleID string)

MarkUsed marks a specific rule ID (or the directive itself for all-rules) as used.

func (*Directive) RuleIDToken

func (d *Directive) RuleIDToken(ruleID string) *token.Token

RuleIDToken returns a synthetic token pointing to a specific rule ID within the comment. Used for diagnostic positioning on per-rule errors.

Jump to

Keyboard shortcuts

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