analyze

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	Pass     string // pass that produced it: "complexity", "lint", "security"
	Rule     string // rule id, e.g. "high-complexity", "unused-local"
	Severity Severity
	Message  string
	Line     int
}

Finding is a single issue reported by a pass.

type Metrics

type Metrics struct {
	Lines           int
	Functions       int // excludes the main chunk
	MaxComplexity   int
	TotalComplexity int
}

Metrics are whole-program counts gathered during analysis.

type Options

type Options struct {
	MaxComplexity int // functions above this are flagged; default 10
}

Options configures the analysis.

type Pass

type Pass interface {
	Name() string
	Run(prog *ast.Program, opts Options, rep *Report)
}

Pass is one analysis stage. New checks are added by appending to passes.

type Report

type Report struct {
	Findings []Finding
	Metrics  Metrics
}

Report is the full result of analyzing one source file.

func Analyze

func Analyze(src string, opts Options) (*Report, error)

Analyze parses src and runs every registered pass over it. A parse error is returned as-is (no findings); otherwise the populated *Report is returned.

func (*Report) String

func (r *Report) String() string

String renders the report as human-readable text.

type Severity

type Severity int

Severity ranks a finding's importance.

const (
	SeverityInfo Severity = iota
	SeverityWarning
	SeverityError
)

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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