heuristics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package heuristics implements the built-in mem-guard checks. Each Heuristic inspects an analysis.Context and returns finding.Findings for patterns that may cause unbounded memory growth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendInLoop

type AppendInLoop struct{}

AppendInLoop detects append() calls inside unbounded loop bodies.

func (*AppendInLoop) Check

func (h *AppendInLoop) Check(ctx *analysis.Context) []finding.Finding

func (*AppendInLoop) Description

func (h *AppendInLoop) Description() string

func (*AppendInLoop) Name

func (h *AppendInLoop) Name() string

type ChannelDrivenGrowth

type ChannelDrivenGrowth struct{}

ChannelDrivenGrowth detects collecting from channels into growing data structures.

func (*ChannelDrivenGrowth) Check

func (*ChannelDrivenGrowth) Description

func (h *ChannelDrivenGrowth) Description() string

func (*ChannelDrivenGrowth) Name

func (h *ChannelDrivenGrowth) Name() string

type CrossBoundaryGrowth

type CrossBoundaryGrowth struct{}

CrossBoundaryGrowth detects loops that call functions which grow passed-in collections via pointer or map reference.

func (*CrossBoundaryGrowth) Check

func (*CrossBoundaryGrowth) Description

func (h *CrossBoundaryGrowth) Description() string

func (*CrossBoundaryGrowth) Name

func (h *CrossBoundaryGrowth) Name() string

type GoroutineSpawnInLoop

type GoroutineSpawnInLoop struct{}

GoroutineSpawnInLoop detects go statements inside unbounded loops.

func (*GoroutineSpawnInLoop) Check

func (*GoroutineSpawnInLoop) Description

func (h *GoroutineSpawnInLoop) Description() string

func (*GoroutineSpawnInLoop) Name

func (h *GoroutineSpawnInLoop) Name() string

type Heuristic

type Heuristic interface {
	Name() string
	Description() string
	Check(ctx *analysis.Context) []finding.Finding
}

Heuristic defines the interface for a single analysis check.

func Default

func Default() []Heuristic

Default returns a fresh slice of the built-in heuristics.

type MapGrowInLoop

type MapGrowInLoop struct{}

MapGrowInLoop detects map key assignments inside unbounded loop bodies.

func (*MapGrowInLoop) Check

func (h *MapGrowInLoop) Check(ctx *analysis.Context) []finding.Finding

func (*MapGrowInLoop) Description

func (h *MapGrowInLoop) Description() string

func (*MapGrowInLoop) Name

func (h *MapGrowInLoop) Name() string

type RecursiveAccumulator

type RecursiveAccumulator struct{}

RecursiveAccumulator detects recursive functions that grow a collection parameter without a visible depth limit.

func (*RecursiveAccumulator) Check

func (*RecursiveAccumulator) Description

func (h *RecursiveAccumulator) Description() string

func (*RecursiveAccumulator) Name

func (h *RecursiveAccumulator) Name() string

type UnboundedConcat

type UnboundedConcat struct{}

UnboundedConcat detects string concatenation in unbounded loops.

func (*UnboundedConcat) Check

func (h *UnboundedConcat) Check(ctx *analysis.Context) []finding.Finding

func (*UnboundedConcat) Description

func (h *UnboundedConcat) Description() string

func (*UnboundedConcat) Name

func (h *UnboundedConcat) Name() string

Jump to

Keyboard shortcuts

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