Documentation
¶
Overview ¶
Package nolint provides shared helpers for nolint-directive detection used by linters within pkg/linters.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Analyzer = &analysis.Analyzer{ Name: "nolintindex", Doc: "indexes nolint directives for gh-aw custom linters", ResultType: reflect.TypeFor[DirectiveIndex](), RunDespiteErrors: true, Run: func(pass *analysis.Pass) (any, error) { return BuildDirectiveIndex(pass), nil }, }
Analyzer builds a shared nolint directive index once per package so analyzers can reuse it via pass.ResultOf.
Functions ¶
func HasDirectiveForLinter ¶ added in v0.82.10
func HasDirectiveForLinter(position token.Position, idx DirectiveIndex, linterName string) bool
HasDirectiveForLinter reports whether the given source position is covered by a suppression directive for linterName (or "nolint:all"). Both same-line and previous-line directives are recognised, matching golangci-lint behaviour.
func ImplementsError ¶
ImplementsError reports whether t implements the built-in error interface.
Types ¶
type DirectiveIndex ¶ added in v0.82.10
DirectiveIndex records nolint directives by filename, line, and linter name.
func BuildDirectiveIndex ¶ added in v0.82.10
func BuildDirectiveIndex(pass *analysis.Pass) DirectiveIndex
BuildDirectiveIndex scans all comments in the analysis pass and returns a map from filename → line → set of linter names that carry a nolint directive.