analyzer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForEachFile

func ForEachFile[T any](files []string, fn func(string) (T, error)) []T

ForEachFile processes files in parallel, calling fn for each file. No parser is provided; use this for non-AST operations (e.g., SATD scanning). Uses 2x NumCPU workers by default.

func ForEachFileWithProgress

func ForEachFileWithProgress[T any](files []string, fn func(string) (T, error), onProgress ProgressFunc) []T

ForEachFileWithProgress processes files in parallel with optional progress callback.

func MapFiles

func MapFiles[T any](files []string, fn func(*parser.Parser, string) (T, error)) []T

MapFiles processes files in parallel, calling fn for each file with a dedicated parser. Results are collected and returned in arbitrary order. Errors from individual files are silently skipped. Uses 2x NumCPU workers by default (optimal for mixed I/O and CGO workloads).

func MapFilesN

func MapFilesN[T any](files []string, maxWorkers int, fn func(*parser.Parser, string) (T, error), onProgress ProgressFunc) []T

MapFilesN processes files with a configurable worker count. If maxWorkers is <= 0, defaults to 2x NumCPU.

func MapFilesWithProgress

func MapFilesWithProgress[T any](files []string, fn func(*parser.Parser, string) (T, error), onProgress ProgressFunc) []T

MapFilesWithProgress processes files in parallel with optional progress callback.

Types

type ChurnAnalyzer

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

ChurnAnalyzer analyzes git commit history for file churn.

func NewChurnAnalyzer

func NewChurnAnalyzer(days int) *ChurnAnalyzer

NewChurnAnalyzer creates a new churn analyzer.

func (*ChurnAnalyzer) AnalyzeFiles

func (a *ChurnAnalyzer) AnalyzeFiles(repoPath string, files []string) (*models.ChurnAnalysis, error)

AnalyzeFiles analyzes churn for specific files.

func (*ChurnAnalyzer) AnalyzeRepo

func (a *ChurnAnalyzer) AnalyzeRepo(repoPath string) (*models.ChurnAnalysis, error)

AnalyzeRepo analyzes git history for a repository.

func (*ChurnAnalyzer) SetSpinner

func (a *ChurnAnalyzer) SetSpinner(spinner *progress.Tracker)

SetSpinner sets a spinner for progress indication during analysis.

type ComplexityAnalyzer

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

ComplexityAnalyzer computes cyclomatic and cognitive complexity.

func NewComplexityAnalyzer

func NewComplexityAnalyzer() *ComplexityAnalyzer

NewComplexityAnalyzer creates a new complexity analyzer.

func (*ComplexityAnalyzer) AnalyzeFile

func (a *ComplexityAnalyzer) AnalyzeFile(path string) (*models.FileComplexity, error)

AnalyzeFile analyzes complexity for a single file.

func (*ComplexityAnalyzer) AnalyzeProject

func (a *ComplexityAnalyzer) AnalyzeProject(files []string) (*models.ComplexityAnalysis, error)

AnalyzeProject analyzes all files in a project using parallel processing.

func (*ComplexityAnalyzer) AnalyzeProjectWithProgress

func (a *ComplexityAnalyzer) AnalyzeProjectWithProgress(files []string, onProgress ProgressFunc) (*models.ComplexityAnalysis, error)

AnalyzeProjectWithProgress analyzes all files with optional progress callback.

func (*ComplexityAnalyzer) Close

func (a *ComplexityAnalyzer) Close()

Close releases analyzer resources.

type DeadCodeAnalyzer

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

DeadCodeAnalyzer detects unused functions, variables, and unreachable code.

func NewDeadCodeAnalyzer

func NewDeadCodeAnalyzer(confidence float64) *DeadCodeAnalyzer

NewDeadCodeAnalyzer creates a new dead code analyzer.

func (*DeadCodeAnalyzer) AnalyzeFile

func (a *DeadCodeAnalyzer) AnalyzeFile(path string) (*fileDeadCode, error)

AnalyzeFile analyzes a single file for dead code.

func (*DeadCodeAnalyzer) AnalyzeProject

func (a *DeadCodeAnalyzer) AnalyzeProject(files []string) (*models.DeadCodeAnalysis, error)

AnalyzeProject analyzes dead code across a project using parallel processing.

func (*DeadCodeAnalyzer) AnalyzeProjectWithProgress

func (a *DeadCodeAnalyzer) AnalyzeProjectWithProgress(files []string, onProgress ProgressFunc) (*models.DeadCodeAnalysis, error)

AnalyzeProjectWithProgress analyzes dead code with optional progress callback.

func (*DeadCodeAnalyzer) Close

func (a *DeadCodeAnalyzer) Close()

Close releases analyzer resources.

type DefectAnalyzer

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

DefectAnalyzer predicts defect probability using PMAT weights.

func NewDefectAnalyzer

func NewDefectAnalyzer(churnDays int) *DefectAnalyzer

NewDefectAnalyzer creates a new defect analyzer with default PMAT weights.

func (*DefectAnalyzer) AnalyzeProject

func (a *DefectAnalyzer) AnalyzeProject(repoPath string, files []string) (*models.DefectAnalysis, error)

AnalyzeProject predicts defects across a project.

func (*DefectAnalyzer) Close

func (a *DefectAnalyzer) Close()

Close releases analyzer resources.

type DuplicateAnalyzer

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

DuplicateAnalyzer detects code clones using MinHash.

func NewDuplicateAnalyzer

func NewDuplicateAnalyzer(minLines int, threshold float64) *DuplicateAnalyzer

NewDuplicateAnalyzer creates a new duplicate analyzer.

func (*DuplicateAnalyzer) AnalyzeProject

func (a *DuplicateAnalyzer) AnalyzeProject(files []string) (*models.CloneAnalysis, error)

AnalyzeProject detects code clones across a project.

func (*DuplicateAnalyzer) AnalyzeProjectWithProgress

func (a *DuplicateAnalyzer) AnalyzeProjectWithProgress(files []string, onProgress ProgressFunc) (*models.CloneAnalysis, error)

AnalyzeProjectWithProgress detects code clones with optional progress callback.

func (*DuplicateAnalyzer) Close

func (a *DuplicateAnalyzer) Close()

Close releases analyzer resources.

type GraphAnalyzer

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

GraphAnalyzer builds dependency graphs from source code.

func NewGraphAnalyzer

func NewGraphAnalyzer(scope GraphScope) *GraphAnalyzer

NewGraphAnalyzer creates a new graph analyzer.

func (*GraphAnalyzer) AnalyzeProject

func (a *GraphAnalyzer) AnalyzeProject(files []string) (*models.DependencyGraph, error)

AnalyzeProject builds a dependency graph for a project.

func (*GraphAnalyzer) AnalyzeProjectWithProgress

func (a *GraphAnalyzer) AnalyzeProjectWithProgress(files []string, onProgress ProgressFunc) (*models.DependencyGraph, error)

AnalyzeProjectWithProgress builds a dependency graph with optional progress callback.

func (*GraphAnalyzer) CalculateMetrics

func (a *GraphAnalyzer) CalculateMetrics(graph *models.DependencyGraph) *models.GraphMetrics

CalculateMetrics computes graph metrics like PageRank.

func (*GraphAnalyzer) Close

func (a *GraphAnalyzer) Close()

Close releases analyzer resources.

type GraphScope

type GraphScope string

GraphScope determines the granularity of graph nodes.

const (
	ScopeFile     GraphScope = "file"
	ScopeFunction GraphScope = "function"
	ScopeModule   GraphScope = "module"
	ScopePackage  GraphScope = "package"
)

type ProgressFunc

type ProgressFunc func()

ProgressFunc is called after each file is processed.

type SATDAnalyzer

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

SATDAnalyzer detects self-admitted technical debt markers.

func NewSATDAnalyzer

func NewSATDAnalyzer() *SATDAnalyzer

NewSATDAnalyzer creates a new SATD analyzer with default patterns.

func (*SATDAnalyzer) AddPattern

func (a *SATDAnalyzer) AddPattern(pattern string, category models.DebtCategory, severity models.Severity) error

AddPattern adds a custom SATD detection pattern.

func (*SATDAnalyzer) AnalyzeFile

func (a *SATDAnalyzer) AnalyzeFile(path string) ([]models.TechnicalDebt, error)

AnalyzeFile scans a file for SATD markers.

func (*SATDAnalyzer) AnalyzeProject

func (a *SATDAnalyzer) AnalyzeProject(files []string) (*models.SATDAnalysis, error)

AnalyzeProject scans all files in a project for SATD using parallel processing.

func (*SATDAnalyzer) AnalyzeProjectWithProgress

func (a *SATDAnalyzer) AnalyzeProjectWithProgress(files []string, onProgress ProgressFunc) (*models.SATDAnalysis, error)

AnalyzeProjectWithProgress scans all files with optional progress callback.

type TDGAnalyzer

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

TDGAnalyzer calculates Technical Debt Gradient scores.

func NewTDGAnalyzer

func NewTDGAnalyzer(churnDays int) *TDGAnalyzer

NewTDGAnalyzer creates a new TDG analyzer with default weights.

func (*TDGAnalyzer) AnalyzeProject

func (a *TDGAnalyzer) AnalyzeProject(repoPath string, files []string) (*models.TDGAnalysis, error)

AnalyzeProject calculates TDG scores for a project.

func (*TDGAnalyzer) Close

func (a *TDGAnalyzer) Close()

Close releases analyzer resources.

Jump to

Keyboard shortcuts

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