nolint

package
v0.82.10 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package nolint provides shared helpers for nolint-directive detection used by linters within pkg/linters.

Index

Constants

This section is empty.

Variables

View Source
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

func ImplementsError(t types.Type) bool

ImplementsError reports whether t implements the built-in error interface.

Types

type DirectiveIndex added in v0.82.10

type DirectiveIndex map[string]map[int]map[string]struct{}

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.

func Index added in v0.82.10

func Index(pass *analysis.Pass) (DirectiveIndex, error)

Index returns the shared nolint directive index for pass.

Jump to

Keyboard shortcuts

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