Help us shape the future of Go! Take the 2026 Go Developer Survey

analyzer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortIssuesBySeverity

func SortIssuesBySeverity(issues []*Issue)

SortIssuesBySeverity sorts issues by severity and then by file

Types

type AggregateMetrics

type AggregateMetrics struct {
	AverageFunctionLength float64         `json:"average_function_length"`
	FunctionLengthP95     int             `json:"function_length_p95"` // 95th percentile
	CommentRatio          float64         `json:"comment_ratio"`       // Overall comment ratio
	LargestFiles          []*FileSize     `json:"largest_files"`       // Top 10
	AverageComplexity     float64         `json:"average_complexity"`
	ComplexityP95         int             `json:"complexity_p95"`         // 95th percentile
	MostComplexFunctions  []*FunctionInfo `json:"most_complex_functions"` // Top 10
}

AggregateMetrics contains aggregated metrics across all files

type AnalysisResult

type AnalysisResult struct {
	ProjectPath    string            `json:"project_path"`
	TotalFiles     int               `json:"total_files"`
	TotalLines     int               `json:"total_lines"`
	TotalCodeLines int               `json:"total_code_lines"`
	TotalFunctions int               `json:"total_functions"`
	Metrics        *AggregateMetrics `json:"metrics"`
	Files          []*FileAnalysis   `json:"files"`
	Issues         []*Issue          `json:"issues"`
	Coverage       *CoverageReport   `json:"coverage,omitempty"`
	Dependencies   *DependencyReport `json:"dependencies,omitempty"`
}

AnalysisResult contains the complete analysis of a codebase

type Analyzer

type Analyzer interface {
	// Analyze takes parsed file metrics and produces an analysis result
	Analyze(projectPath string, metrics []*parserPkg.FileMetrics) (*AnalysisResult, error)
}

Analyzer defines the interface for analyzing parsed code metrics

func NewAnalyzer

func NewAnalyzer(cfg *config.AnalysisConfig) Analyzer

NewAnalyzer creates a new MetricsAnalyzer with the given configuration

type CircularDependency added in v0.2.0

type CircularDependency struct {
	Cycle []string `json:"cycle"` // The circular dependency chain
}

CircularDependency represents a circular dependency between packages

type CoverageReport added in v0.2.0

type CoverageReport struct {
	Packages         []*PackageCoverage `json:"packages"`
	AverageCoverage  float64            `json:"average_coverage"`
	LowCoverageCount int                `json:"low_coverage_count"`
}

CoverageReport contains test coverage information

type DependencyReport added in v0.2.0

type DependencyReport struct {
	Packages             []*PackageDependencies `json:"packages"`
	CircularDependencies []*CircularDependency  `json:"circular_dependencies,omitempty"`
	TotalPackages        int                    `json:"total_packages"`
	HighImportCount      int                    `json:"high_import_count"`   // Packages exceeding import threshold
	HighExternalCount    int                    `json:"high_external_count"` // Packages with too many external deps
}

DependencyReport contains dependency analysis information

type FileAnalysis

type FileAnalysis struct {
	Path      string              `json:"path"`
	Metrics   *parser.FileMetrics `json:"metrics"`
	LargeFile bool                `json:"large_file"` // Exceeds threshold
}

FileAnalysis contains analysis for a single file

type FileSize

type FileSize struct {
	Path  string `json:"path"`
	Lines int    `json:"lines"`
}

FileSize represents a file and its line count

type FunctionInfo added in v0.2.0

type FunctionInfo struct {
	File       string `json:"file"`
	Function   string `json:"function"`
	Complexity int    `json:"complexity"`
	Lines      int    `json:"lines"`
}

FunctionInfo represents function information for reporting

type Issue

type Issue = detectors.Issue

Issue is an alias for detectors.Issue for backward compatibility

type MetricsAnalyzer

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

MetricsAnalyzer implements Analyzer for basic metrics analysis

func (*MetricsAnalyzer) Analyze

func (ma *MetricsAnalyzer) Analyze(projectPath string, metrics []*parserPkg.FileMetrics) (*AnalysisResult, error)

Analyze performs analysis on the parsed metrics

type PackageCoverage added in v0.2.0

type PackageCoverage struct {
	PackagePath string  `json:"package_path"`
	Coverage    float64 `json:"coverage"`
	Error       string  `json:"error,omitempty"`
	Skipped     bool    `json:"skipped"`
}

PackageCoverage represents coverage for a single package

type PackageDependencies added in v0.2.0

type PackageDependencies struct {
	PackageName         string   `json:"package_name"`
	StdlibImports       []string `json:"stdlib_imports"`
	InternalImports     []string `json:"internal_imports"`
	ExternalImports     []string `json:"external_imports"`
	TotalImports        int      `json:"total_imports"`
	ExternalImportCount int      `json:"external_import_count"`
}

PackageDependencies represents dependency information for a single package

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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