linters

package
v0.74.5 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 1 Imported by: 0

README

linters Package

The linters package namespace contains custom static analysis linters used by gh-aw quality checks.

Overview

This package currently provides custom Go analyzers in the following subpackages:

  • excessivefuncparams — reports function declarations that exceed a configurable parameter-count threshold.
  • errormessage — reports non-actionable error-message patterns in changed files.
  • largefunc — reports function bodies that exceed a configurable line-count threshold.
  • osexitinlibrary — reports os.Exit calls in library packages (pkg/*) where process termination should be delegated to cmd/* entry points.
  • ssljson — validates ssl.json skill artifacts found in .github/skills/ against the SSL spec (enum membership, graph integrity, transition targets, entry pointer validity).

Public API

Subpackages
Subpackage Description
excessivefuncparams Custom go/analysis analyzer that flags function declarations with too many positional parameters
errormessage Custom go/analysis analyzer that flags non-actionable error message patterns in changed files
largefunc Custom go/analysis analyzer that flags large functions with actionable diagnostics
osexitinlibrary Custom go/analysis analyzer that flags os.Exit usage in library packages
ssljson Custom go/analysis analyzer that validates SSL JSON skill artifacts in .github/skills/
Namespace exports
Symbol Description
ErrorMessageAnalyzer Compatibility alias to pkg/linters/errormessage.Analyzer

Usage Examples

import (
	"github.com/github/gh-aw/pkg/linters/excessivefuncparams"
	"github.com/github/gh-aw/pkg/linters/errormessage"
	"github.com/github/gh-aw/pkg/linters/largefunc"
	"github.com/github/gh-aw/pkg/linters/osexitinlibrary"
	"github.com/github/gh-aw/pkg/linters/ssljson"
)

// Use with multichecker, singlechecker, or custom go/analysis driver.
_ = excessivefuncparams.Analyzer
_ = errormessage.Analyzer
_ = largefunc.Analyzer
_ = osexitinlibrary.Analyzer
_ = ssljson.Analyzer

Dependencies

Internal:

  • pkg/linters/errormessage (via namespace compatibility export ErrorMessageAnalyzer).

External:

  • golang.org/x/tools/go/analysis — analyzer framework
  • golang.org/x/tools/go/analysis/passes/inspect — AST inspection support
  • golang.org/x/tools/go/ast/inspector — efficient AST traversal

Design Notes

  • The package is intentionally organized as a namespace (pkg/linters/*) so individual analyzers remain isolated and independently testable.
  • excessivefuncparams exposes a -max-params analyzer flag and defaults to 8 parameters (DefaultMaxParams).
  • largefunc exposes a -max-lines analyzer flag and defaults to 60 lines (DefaultMaxLines).
  • osexitinlibrary helps enforce separation between library logic and process-level termination.

This specification is automatically maintained by the spec-extractor workflow.

Documentation

Overview

Package linters is a namespace for gh-aw's custom Go analysis linters.

The actual analyzers are implemented in subpackages — see the excessivefuncparams, errormessage, largefunc, and osexitinlibrary subdirectories for analyzer entry points. The package also exposes a compatibility alias (ErrorMessageAnalyzer) that points to the errormessage subpackage analyzer.

Index

Constants

This section is empty.

Variables

View Source
var ErrorMessageAnalyzer = errormessage.Analyzer

ErrorMessageAnalyzer exposes the actionable error-message analyzer.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
Package ctxbackground implements a Go analysis linter that flags calls to context.Background() inside functions that already receive a context.Context parameter.
Package ctxbackground implements a Go analysis linter that flags calls to context.Background() inside functions that already receive a context.Context parameter.
Package errormessage implements a Go analysis linter that enforces actionable error-message patterns in changed files.
Package errormessage implements a Go analysis linter that enforces actionable error-message patterns in changed files.
Package errstringmatch implements a Go analysis linter that flags calls to strings.Contains(err.Error(), "literal") that perform brittle substring matching on error messages instead of using errors.Is or errors.As.
Package errstringmatch implements a Go analysis linter that flags calls to strings.Contains(err.Error(), "literal") that perform brittle substring matching on error messages instead of using errors.Is or errors.As.
Package excessivefuncparams implements a Go analysis linter that flags functions with too many positional parameters.
Package excessivefuncparams implements a Go analysis linter that flags functions with too many positional parameters.
Package largefunc implements a Go analysis linter that flags functions whose body exceeds a configurable line threshold.
Package largefunc implements a Go analysis linter that flags functions whose body exceeds a configurable line threshold.
Package osexitinlibrary implements a Go analysis linter that flags os.Exit calls in library (pkg/) packages.
Package osexitinlibrary implements a Go analysis linter that flags os.Exit calls in library (pkg/) packages.
Package rawloginlib implements a Go analysis linter that flags standard log package calls in library (pkg/) packages.
Package rawloginlib implements a Go analysis linter that flags standard log package calls in library (pkg/) packages.
Package ssljson implements a Go analysis linter that validates .github/skills/*/ssl.json files against the SSL specification rules.
Package ssljson implements a Go analysis linter that validates .github/skills/*/ssl.json files against the SSL specification rules.

Jump to

Keyboard shortcuts

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