coverage

package
v0.87.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 8 Imported by: 0

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

func RegisterHotThresholdFlag(a *analysis.Analyzer) *int

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

func ShouldApply(pass *analysis.Pass, pos token.Pos, threshold int) bool

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.

Jump to

Keyboard shortcuts

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