suppress

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package suppress implements signal control SC2 (ADR-0027): inline, in-source suppression of a single finding via a visible, reasoned comment marker on (or directly above) the offending line.

The marker is `commitbrief-ignore: <reason>` or `commitbrief-ignore[<severity>]: <reason>`. A scoped marker silences only that severity on the line; an unscoped marker silences any. The reason is everything after the colon and is required only insofar as the marker must parse — an empty reason still suppresses, but the syntax is documented as "give a reason".

Unlike the user-private baseline, a suppression marker lives in committed source: a reviewer sees it in the diff, so it cannot be used to silently hide a real bug from a senior. That is why suppression carries none of the baseline's team-shared hide-vector risk.

Markers are read from the ADDED lines of the diff (the new content of the change under review). The comment prefix is not parsed — the `commitbrief-ignore` token is matched language-independently, so `//`, `#`, `--`, and `/* ... */` comments all work without a per-language table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(findings []render.Finding, sup Suppressions) (kept []render.Finding, suppressed int)

Filter splits findings into the ones to KEEP and a count of how many were dropped by an inline suppression. A finding is dropped when a matching marker sits on its own line OR on the line directly above it (line-1) — the "above" case is the idiomatic placement when the offending statement is long or the marker would clutter the line. This is a TRUE removal (ADR-0027): the kept slice feeds fail-on, JSON findings[], and display alike. An empty suppression map keeps everything. The kept slice is always non-nil so the nil-means-degrade invariant downstream is preserved.

Types

type Rule

type Rule struct {
	Severity render.Severity
	Reason   string
}

Rule is one parsed suppression directive bound to a new-file line number. Severity is "" for an unscoped marker (suppresses any finding on the line) or one of the five canonical levels for a scoped marker. Reason is the free text after the colon, trimmed; it is retained so a future surface (or audit log) can echo why a finding was silenced.

type Suppressions

type Suppressions map[int]Rule

Suppressions maps a new-file line number to the directive found on that line. Only one directive per line is retained (the first match wins; a line with two markers is pathological and not worth modeling).

func ParseSuppressions

func ParseSuppressions(d diff.Diff) Suppressions

ParseSuppressions scans the ADDED lines of d for commitbrief-ignore markers and returns them keyed by their new-file line number — the same 1-based numbering a finding's Line field uses (see diff.NumberedString). Context and removed lines are ignored: a suppression must be part of the change under review, not pre-existing untouched code. Returns an empty (non-nil) map when there are no markers.

Jump to

Keyboard shortcuts

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