Documentation
¶
Overview ¶
Package coverage provides helpers for coverage-aware perf linter gating.
When the GH_AW_LINT_COVERAGE_PROFILE environment variable points to a Go coverage profile (produced by "go test -covermode=count -coverprofile=<path>"), ShouldApply returns false for code positions whose recorded hit count is below the configured threshold, suppressing findings on cold paths.
When the variable is unset (the default), every call to ShouldApply returns true so all gated linters behave exactly as before.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHotThresholdFlag ¶
RegisterHotThresholdFlag registers a -hot-threshold flag on the given analyzer and returns a pointer to the flag value. The default value is 1 (gate on any recorded execution). Pass 0 to disable gating entirely.
This function must be called from an init() function, not from the analyzer Run function, to avoid an analyzer initialisation cycle.
func ShouldApply ¶
ShouldApply reports whether a linter finding at pos should be reported.
- When threshold is 0, coverage gating is disabled and the function always returns true.
- When no coverage profile is loaded (GH_AW_LINT_COVERAGE_PROFILE is unset or the file cannot be parsed), the function always returns true (permissive fallback).
- Otherwise it returns true only when the recorded hit count for the position's line is >= threshold.
Types ¶
This section is empty.