analyzer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzerContext

type AnalyzerContext struct {
	// Fset holds the parsed file set for position information.
	Fset *token.FileSet

	// Types contains type-checker results.
	Types *types.Info

	// SSA contains the SSA function representation of the current package.
	SSA *ssa.Package

	// Filename represents the absolute or relative path of the file being analyzed.
	Filename string

	// PackageName is the Go package name.
	PackageName string

	// Source holds the entire source code of the file (optional, useful for highlighting).
	Source []byte

	// CustomData is a generic key-value map that allows analyzers to store state.
	CustomData map[string]any

	// Rules stores registered rules for analysis
	Rules []*Rule

	// Issues stores found issues during analysis
	Issues []result.Issue
}

AnalyzerContext represents the shared context used during all analysis phases.

func NewAnalyzerContext

func NewAnalyzerContext(
	fset *token.FileSet,
	typesInfo *types.Info,
	ssaPkg *ssa.Package,
	filename string,
	packageName string,
	source []byte,
) *AnalyzerContext

NewAnalyzerContext creates a new AnalyzerContext instance.

func (*AnalyzerContext) ClearIssues

func (ctx *AnalyzerContext) ClearIssues()

ClearIssues clears all reported issues.

func (*AnalyzerContext) GetCustom

func (ctx *AnalyzerContext) GetCustom(key string) (any, bool)

GetCustom retrieves a value from the CustomData map.

func (*AnalyzerContext) GetFset

func (ctx *AnalyzerContext) GetFset() *token.FileSet

GetFset returns the file set for position information.

func (*AnalyzerContext) GetIssues

func (ctx *AnalyzerContext) GetIssues() []result.Issue

GetIssues returns all reported issues.

func (*AnalyzerContext) Info

func (ctx *AnalyzerContext) Info() *types.Info

Info returns the types info.

func (*AnalyzerContext) RegisterRule

func (ctx *AnalyzerContext) RegisterRule(rule *Rule)

RegisterRule registers a rule with the analyzer context.

func (*AnalyzerContext) Report

func (ctx *AnalyzerContext) Report(issue result.Issue)

Report reports an issue found during analysis.

func (*AnalyzerContext) SetCustom

func (ctx *AnalyzerContext) SetCustom(key string, value any)

SetCustom sets a value in the CustomData map.

type Rule

type Rule struct {
	ID       string
	Title    string
	Category string
	Severity result.Severity
	Summary  string
	Matcher  func(*AnalyzerContext, *analysis.Pass)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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