suppressions

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: 0BSD Imports: 11 Imported by: 0

Documentation

Overview

Package suppressions parses and owns physical lint-suppression ranges.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(file *source.File, options ParseOptions) (Index, []Problem)

Parse validates Glippy suppression directives and assigns physical targets.

func ValidateStable

func ValidateStable(before, after physicalSource) error

ValidateStable verifies that every structurally valid suppression continues to own the same normalized physical tokens after a source transformation. Rule registration and configurable reason or expiry policy deliberately do not participate because formatting must be stable without lint configuration.

Types

type Application

type Application struct {
	Diagnostics []rules.Diagnostic
	Suppressed  []SuppressedDiagnostic
	Unused      []Directive
}

Application is one deterministic suppression pass over ordered diagnostics.

type Directive

type Directive struct {
	Scope     Scope
	RuleID    string
	Range     source.Range
	Target    source.Range
	Reason    string
	ExpiresOn string
}

Directive is one validated exact-rule suppression.

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index is an immutable source-ordered suppression set.

func (Index) Apply

func (i Index) Apply(diagnostics []rules.Diagnostic) Application

Apply removes matched diagnostics and reports used and unused directives.

func (Index) Directives

func (i Index) Directives() []Directive

Directives returns an independent source-ordered suppression snapshot.

func (Index) Match

func (i Index) Match(diagnostic rules.Diagnostic) (Directive, bool)

Match returns the first source-ordered directive owning a diagnostic start.

type ParseOptions

type ParseOptions struct {
	KnownRules    []string
	RequireReason bool
	ExpiryCutoff  string
}

ParseOptions supplies registry, reason, and deterministic expiry policy.

type Problem

type Problem struct {
	Kind    ProblemKind
	Range   source.Range
	Message string
}

Problem is one source-ordered suppression diagnostic.

type ProblemKind

type ProblemKind string

ProblemKind classifies one suppression or parser-configuration defect.

const (
	ProblemMalformed            ProblemKind = "malformed"
	ProblemUnknownRule          ProblemKind = "unknown-rule"
	ProblemMissingReason        ProblemKind = "missing-reason"
	ProblemInvalidExpiry        ProblemKind = "invalid-expiry"
	ProblemExpired              ProblemKind = "expired"
	ProblemMisplacedFileScope   ProblemKind = "misplaced-file-scope"
	ProblemUnmatchedRangeEnd    ProblemKind = "unmatched-range-end"
	ProblemNestedRange          ProblemKind = "nested-range"
	ProblemUnclosedRange        ProblemKind = "unclosed-range"
	ProblemInvalidConfiguration ProblemKind = "invalid-configuration"
	ProblemLegacyDirective      ProblemKind = "legacy-directive"
)

type Scope

type Scope uint8

Scope identifies the physical ownership policy of one suppression.

const (
	ScopeLine Scope = iota + 1
	ScopeNextLine
	ScopeRange
	ScopeFile
)

type SuppressedDiagnostic

type SuppressedDiagnostic struct {
	Diagnostic rules.Diagnostic
	Directive  Directive
}

SuppressedDiagnostic binds one removed diagnostic to its owning directive.

Jump to

Keyboard shortcuts

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