baseline

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package baseline manages signal suppression state for repeat scans.

Suppressions are stored in .stringer/baseline.json and are intended to be version-controlled. Users suppress signals they have acknowledged, marked as won't-fix, or identified as false positives. On subsequent scans the baseline is loaded and matched against current signals to filter output.

Index

Constants

This section is empty.

Variables

FS is the file system implementation used by this package. Override in tests with a testable.MockFileSystem.

Functions

func AddOrUpdate

func AddOrUpdate(state *BaselineState, s Suppression)

AddOrUpdate adds a new suppression or updates an existing one (matched by SignalID). When updating, the existing entry is replaced entirely.

func IsExpired

func IsExpired(s Suppression) bool

IsExpired returns true if the suppression has an expiration time that is in the past.

func Lookup

func Lookup(state *BaselineState) map[string]Suppression

Lookup builds an O(1) lookup map from SignalID to Suppression.

func Remove

func Remove(state *BaselineState, signalID string) bool

Remove deletes a suppression by SignalID. It returns true if the suppression was found and removed, false otherwise.

func Save

func Save(repoPath string, state *BaselineState) error

Save writes the baseline state to <repoPath>/.stringer/baseline.json. It creates the .stringer directory if it does not exist. The write is atomic: data is first written to a temporary file in the same directory, then renamed to the final path.

func ValidateReason

func ValidateReason(r Reason) error

ValidateReason checks that r is one of the allowed suppression reasons.

Types

type BaselineState

type BaselineState struct {
	Version      string        `json:"version"`
	Suppressions []Suppression `json:"suppressions"`
}

BaselineState is the top-level structure persisted in baseline.json.

func Load

func Load(repoPath string) (*BaselineState, error)

Load reads the baseline file from <repoPath>/.stringer/baseline.json. If the file does not exist, it returns (nil, nil).

type Reason

type Reason string

Reason describes why a signal was suppressed.

const (
	// ReasonAcknowledged indicates the signal was reviewed and accepted.
	ReasonAcknowledged Reason = "acknowledged"

	// ReasonWontFix indicates the signal will not be addressed.
	ReasonWontFix Reason = "won't-fix"

	// ReasonFalsePositive indicates the signal is not a real issue.
	ReasonFalsePositive Reason = "false-positive"
)

type Suppression

type Suppression struct {
	SignalID     string     `json:"signal_id"`
	Reason       Reason     `json:"reason"`
	Comment      string     `json:"comment,omitempty"`
	SuppressedBy string     `json:"suppressed_by,omitempty"`
	SuppressedAt time.Time  `json:"suppressed_at"`
	ExpiresAt    *time.Time `json:"expires_at,omitempty"`
}

Suppression records a single suppressed signal.

Jump to

Keyboard shortcuts

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