analyzer

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNestedLoops    = 3
	MaxFunctionParams = 5
	MaxSliceCapacity  = 1000
	MaxMapCapacity    = 100
	MaxSearchDepth    = 10
)

Numeric constants for performance thresholds

Variables

This section is empty.

Functions

func Analyze

func Analyze(
	filename string, file *ast.File, fset *token.FileSet, enabledAnalyzers map[string]bool,
) []*models.Issue

Analyze is the main entry point with configuration support

func AnalyzeAll added in v0.11.2

func AnalyzeAll(filename string, file *ast.File, fset *token.FileSet) []*models.Issue

AnalyzeAll is the main entry point for code analysis with caching support

func AnalyzeDependencies

func AnalyzeDependencies(projectPath string) []*models.Issue

AnalyzeDependencies runs dependency analysis once for the entire project

func FilterIssuesByComments added in v0.11.2

func FilterIssuesByComments(issues []*models.Issue, fset *token.FileSet, file *ast.File) []*models.Issue

FilterIssuesByComments FilterIssues removes issues that should be ignored based on comments

func GetLoopDepth added in v0.11.2

func GetLoopDepth(root, target ast.Node) int

GetLoopDepth returns the nesting depth of loops for a node

func IsInLoop added in v0.11.2

func IsInLoop(root, target ast.Node) bool

IsInLoop checks if a node is inside a loop by traversing the AST

func LoadTypes added in v0.11.2

func LoadTypes(fset *token.FileSet, file *ast.File, filename string) (*types.Info, error)

LoadTypes performs type-checking for the file identified by filename. It attempts to load package information via go/packages and falls back to single-file type checking if necessary.

func WalkWithContext added in v0.11.2

func WalkWithContext(node ast.Node, fn func(n ast.Node, ctx *AnalysisContext) bool)

WalkWithContext provides context-aware AST traversal

Types

type AIBullshitAnalyzer

type AIBullshitAnalyzer struct {
	// contains filtered or unexported fields
}

AIBullshitAnalyzer detects AI-generated bullshit code patterns

func (*AIBullshitAnalyzer) Analyze

func (a *AIBullshitAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*AIBullshitAnalyzer) Name

func (a *AIBullshitAnalyzer) Name() string

type APIMisuseAnalyzer

type APIMisuseAnalyzer struct{}

APIMisuseAnalyzer focuses on high signal API pitfalls (waitgroup misuse, expensive calls in loops, etc.).

func (*APIMisuseAnalyzer) Analyze

func (a *APIMisuseAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*APIMisuseAnalyzer) Name

func (a *APIMisuseAnalyzer) Name() string

type AnalysisCache added in v0.11.2

type AnalysisCache struct {
	// contains filtered or unexported fields
}

AnalysisCache caches analysis results to avoid re-analyzing unchanged files

type AnalysisContext added in v0.11.2

type AnalysisContext struct {
	// Performance metrics (8 bytes)
	StartTime time.Time
	// Pointer fields (8 bytes each)
	FileSet *token.FileSet
	// Map fields (8 bytes each)
	Imports   map[string]bool
	FuncDecls map[string]*ast.FuncDecl
	TypeDecls map[string]*ast.TypeSpec
	// String fields (16 bytes each)
	Filename    string
	CurrentFunc string
	// Integer fields (8 bytes each)
	LoopDepth int
	NodeCount int
	// Boolean field (1 byte) - placed at end to minimize padding
	InLoop bool
}

AnalysisContext provides shared context between analyzers

type Analyzer

type Analyzer interface {
	Name() string
	Analyze(node interface{}, fset *token.FileSet) []*models.Issue
}

func NewAIBullshitAnalyzer

func NewAIBullshitAnalyzer() Analyzer

NewAIBullshitAnalyzer creates a new AI bullshit detector

func NewAPIMisuseAnalyzer

func NewAPIMisuseAnalyzer() Analyzer

func NewCGOAnalyzer added in v0.11.2

func NewCGOAnalyzer() Analyzer

func NewCPUCacheAnalyzer added in v0.11.2

func NewCPUCacheAnalyzer() Analyzer

func NewCPUOptimizationAnalyzer

func NewCPUOptimizationAnalyzer() Analyzer

func NewChannelAnalyzer

func NewChannelAnalyzer() Analyzer

func NewConcurrencyPatternsAnalyzer

func NewConcurrencyPatternsAnalyzer() Analyzer

func NewContextAnalyzer

func NewContextAnalyzer() Analyzer

func NewCryptoAnalyzer added in v0.11.2

func NewCryptoAnalyzer() Analyzer

func NewDatabaseAnalyzer

func NewDatabaseAnalyzer() Analyzer

func NewDeferOptimizationAnalyzer

func NewDeferOptimizationAnalyzer() Analyzer

func NewGCPressureAnalyzer

func NewGCPressureAnalyzer() Analyzer

func NewGoroutineAnalyzer

func NewGoroutineAnalyzer() Analyzer

func NewHTTPClientAnalyzer

func NewHTTPClientAnalyzer() Analyzer

func NewHTTPReuseAnalyzer added in v0.11.2

func NewHTTPReuseAnalyzer() Analyzer

func NewIOBufferAnalyzer added in v0.11.2

func NewIOBufferAnalyzer() Analyzer

func NewInterfaceAnalyzer

func NewInterfaceAnalyzer() Analyzer

func NewLoopAnalyzer

func NewLoopAnalyzer() Analyzer

func NewMapAnalyzer

func NewMapAnalyzer() Analyzer

func NewMemoryLeakAnalyzer

func NewMemoryLeakAnalyzer() Analyzer

func NewNetworkPatternsAnalyzer

func NewNetworkPatternsAnalyzer() Analyzer

func NewPrivacyAnalyzer

func NewPrivacyAnalyzer() Analyzer

func NewRaceConditionAnalyzer

func NewRaceConditionAnalyzer() Analyzer

func NewReflectionAnalyzer

func NewReflectionAnalyzer() Analyzer

func NewRegexAnalyzer

func NewRegexAnalyzer() Analyzer

func NewSerializationAnalyzer added in v0.11.2

func NewSerializationAnalyzer() Analyzer

func NewSliceAnalyzer

func NewSliceAnalyzer() Analyzer

func NewStructLayoutAnalyzer added in v0.11.2

func NewStructLayoutAnalyzer() Analyzer

func NewSyncPoolAnalyzer

func NewSyncPoolAnalyzer() Analyzer

func NewTestCoverageAnalyzer

func NewTestCoverageAnalyzer() Analyzer

func NewTimeAnalyzer

func NewTimeAnalyzer() Analyzer

type AnalyzerWithContext added in v0.11.2

type AnalyzerWithContext struct {
	// contains filtered or unexported fields
}

AnalyzerWithContext provides context-aware analysis

func NewAnalyzerWithContext added in v0.11.2

func NewAnalyzerWithContext(root ast.Node) *AnalyzerWithContext

func (*AnalyzerWithContext) GetNodeLoopDepth added in v0.11.2

func (a *AnalyzerWithContext) GetNodeLoopDepth(node ast.Node) int

func (*AnalyzerWithContext) IsNodeInLoop added in v0.11.2

func (a *AnalyzerWithContext) IsNodeInLoop(node ast.Node) bool

type CGOAnalyzer added in v0.11.2

type CGOAnalyzer struct{}

func (*CGOAnalyzer) Analyze added in v0.11.2

func (ca *CGOAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*CGOAnalyzer) Name added in v0.11.2

func (ca *CGOAnalyzer) Name() string

type CPUCacheAnalyzer added in v0.11.2

type CPUCacheAnalyzer struct{}

func (*CPUCacheAnalyzer) Analyze added in v0.11.2

func (c *CPUCacheAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*CPUCacheAnalyzer) Name added in v0.11.2

func (c *CPUCacheAnalyzer) Name() string

type CPUOptimizationAnalyzer

type CPUOptimizationAnalyzer struct{}

func (*CPUOptimizationAnalyzer) Analyze

func (coa *CPUOptimizationAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*CPUOptimizationAnalyzer) Name

func (coa *CPUOptimizationAnalyzer) Name() string

type CacheEntry added in v0.11.2

type CacheEntry struct {
	Hash      string
	Issues    []*models.Issue
	Timestamp time.Time
}

type ChannelAnalyzer

type ChannelAnalyzer struct{}

func (*ChannelAnalyzer) Analyze

func (ca *ChannelAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*ChannelAnalyzer) Name

func (ca *ChannelAnalyzer) Name() string

type ConcurrencyPatternsAnalyzer

type ConcurrencyPatternsAnalyzer struct{}

ConcurrencyPatternsAnalyzer focuses on high-signal concurrency mistakes.

func (*ConcurrencyPatternsAnalyzer) Analyze

func (cpa *ConcurrencyPatternsAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*ConcurrencyPatternsAnalyzer) Name

func (cpa *ConcurrencyPatternsAnalyzer) Name() string

type ContextAnalyzer

type ContextAnalyzer struct{}

func (*ContextAnalyzer) Analyze

func (ca *ContextAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*ContextAnalyzer) Name

func (ca *ContextAnalyzer) Name() string

type CryptoAnalyzer added in v0.11.2

type CryptoAnalyzer struct{}

func (*CryptoAnalyzer) Analyze added in v0.11.2

func (ca *CryptoAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*CryptoAnalyzer) Name added in v0.11.2

func (ca *CryptoAnalyzer) Name() string

type DatabaseAnalyzer

type DatabaseAnalyzer struct{}

func (*DatabaseAnalyzer) Analyze

func (da *DatabaseAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*DatabaseAnalyzer) Name

func (da *DatabaseAnalyzer) Name() string

type DeferOptimizationAnalyzer

type DeferOptimizationAnalyzer struct{}

func (*DeferOptimizationAnalyzer) Analyze

func (d *DeferOptimizationAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*DeferOptimizationAnalyzer) Name

type DependencyAnalyzer

type DependencyAnalyzer struct{}

func NewDependencyAnalyzer

func NewDependencyAnalyzer(_ string) *DependencyAnalyzer

func (*DependencyAnalyzer) Analyze

func (a *DependencyAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*DependencyAnalyzer) Name

func (a *DependencyAnalyzer) Name() string

type GCPressureAnalyzer

type GCPressureAnalyzer struct{}

func (*GCPressureAnalyzer) Analyze

func (gpa *GCPressureAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*GCPressureAnalyzer) Name

func (gpa *GCPressureAnalyzer) Name() string

type GoroutineAnalyzer

type GoroutineAnalyzer struct{}

func (*GoroutineAnalyzer) Analyze

func (ga *GoroutineAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*GoroutineAnalyzer) Name

func (ga *GoroutineAnalyzer) Name() string

type HTTPClientAnalyzer

type HTTPClientAnalyzer struct{}

func (*HTTPClientAnalyzer) Analyze

func (hca *HTTPClientAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*HTTPClientAnalyzer) Name

func (hca *HTTPClientAnalyzer) Name() string

type HTTPReuseAnalyzer added in v0.11.2

type HTTPReuseAnalyzer struct{}

func (*HTTPReuseAnalyzer) Analyze added in v0.11.2

func (ha *HTTPReuseAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*HTTPReuseAnalyzer) Name added in v0.11.2

func (ha *HTTPReuseAnalyzer) Name() string

type IOBufferAnalyzer added in v0.11.2

type IOBufferAnalyzer struct{}

func (*IOBufferAnalyzer) Analyze added in v0.11.2

func (ia *IOBufferAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*IOBufferAnalyzer) Name added in v0.11.2

func (ia *IOBufferAnalyzer) Name() string

type IgnoreChecker added in v0.11.2

type IgnoreChecker struct {
	// contains filtered or unexported fields
}

IgnoreChecker checks if issues should be ignored based on comments

func NewIgnoreChecker added in v0.11.2

func NewIgnoreChecker(fset *token.FileSet, file *ast.File) *IgnoreChecker

NewIgnoreChecker creates a new ignore checker for a file

func (*IgnoreChecker) ShouldIgnore added in v0.11.2

func (ic *IgnoreChecker) ShouldIgnore(issueType string, line int) bool

ShouldIgnore checks if an issue at a specific line should be ignored

type InterfaceAnalyzer

type InterfaceAnalyzer struct{}

func (*InterfaceAnalyzer) Analyze

func (ia *InterfaceAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*InterfaceAnalyzer) Name

func (ia *InterfaceAnalyzer) Name() string

type LoopAnalyzer

type LoopAnalyzer struct{}

func (*LoopAnalyzer) Analyze

func (la *LoopAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*LoopAnalyzer) Name

func (la *LoopAnalyzer) Name() string

type LoopContext added in v0.11.2

type LoopContext struct {
}

LoopContext provides proper loop detection for analyzers

type MapAnalyzer

type MapAnalyzer struct{}

func (*MapAnalyzer) Analyze

func (ma *MapAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*MapAnalyzer) Name

func (ma *MapAnalyzer) Name() string

type MemoryLeakAnalyzer

type MemoryLeakAnalyzer struct{}

func (*MemoryLeakAnalyzer) Analyze

func (mla *MemoryLeakAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*MemoryLeakAnalyzer) Name

func (mla *MemoryLeakAnalyzer) Name() string

type NetworkPatternsAnalyzer

type NetworkPatternsAnalyzer struct{}

func (*NetworkPatternsAnalyzer) Analyze

func (npa *NetworkPatternsAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*NetworkPatternsAnalyzer) Name

func (npa *NetworkPatternsAnalyzer) Name() string

type PrivacyAnalyzer

type PrivacyAnalyzer struct{}

func (*PrivacyAnalyzer) Analyze

func (p *PrivacyAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*PrivacyAnalyzer) Name

func (p *PrivacyAnalyzer) Name() string

type RaceConditionAnalyzer

type RaceConditionAnalyzer struct{}

func (*RaceConditionAnalyzer) Analyze

func (rca *RaceConditionAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*RaceConditionAnalyzer) Name

func (rca *RaceConditionAnalyzer) Name() string

type ReflectionAnalyzer

type ReflectionAnalyzer struct{}

func (*ReflectionAnalyzer) Analyze

func (ra *ReflectionAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*ReflectionAnalyzer) Name

func (ra *ReflectionAnalyzer) Name() string

type RegexAnalyzer

type RegexAnalyzer struct{}

func (*RegexAnalyzer) Analyze

func (ra *RegexAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*RegexAnalyzer) Name

func (ra *RegexAnalyzer) Name() string

type SerializationAnalyzer added in v0.11.2

type SerializationAnalyzer struct{}

func (*SerializationAnalyzer) Analyze added in v0.11.2

func (sa *SerializationAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*SerializationAnalyzer) Name added in v0.11.2

func (sa *SerializationAnalyzer) Name() string

type SliceAnalyzer

type SliceAnalyzer struct{}

func (*SliceAnalyzer) Analyze

func (sa *SliceAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*SliceAnalyzer) Name

func (sa *SliceAnalyzer) Name() string

type StructLayoutAnalyzer added in v0.11.2

type StructLayoutAnalyzer struct{}

func (*StructLayoutAnalyzer) Analyze added in v0.11.2

func (s *StructLayoutAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*StructLayoutAnalyzer) Name added in v0.11.2

func (s *StructLayoutAnalyzer) Name() string

type SyncPoolAnalyzer

type SyncPoolAnalyzer struct{}

func (*SyncPoolAnalyzer) Analyze

func (spa *SyncPoolAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*SyncPoolAnalyzer) Name

func (spa *SyncPoolAnalyzer) Name() string

type TestCoverageAnalyzer

type TestCoverageAnalyzer struct{}

func (*TestCoverageAnalyzer) Analyze

func (tca *TestCoverageAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*TestCoverageAnalyzer) Name

func (tca *TestCoverageAnalyzer) Name() string

type TimeAnalyzer

type TimeAnalyzer struct{}

func (*TimeAnalyzer) Analyze

func (ta *TimeAnalyzer) Analyze(node interface{}, fset *token.FileSet) []*models.Issue

func (*TimeAnalyzer) Name

func (ta *TimeAnalyzer) Name() string

Jump to

Keyboard shortcuts

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