analyzer

package
v0.1.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: 3 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
}

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"`
}

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 []*parser.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 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 Issue

type Issue struct {
	Severity  string `json:"severity"`  // "warning", "info", "error"
	Type      string `json:"type"`      // "large_file", "long_function", "low_comment_ratio"
	File      string `json:"file"`      // File path
	Line      int    `json:"line"`      // Line number (0 if not applicable)
	Function  string `json:"function"`  // Function name (empty if not applicable)
	Message   string `json:"message"`   // Human-readable message
	Value     int    `json:"value"`     // Actual value (e.g., line count)
	Threshold int    `json:"threshold"` // Threshold value
}

Issue represents a code quality issue found during analysis

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 []*parser.FileMetrics) (*AnalysisResult, error)

Analyze performs analysis on the parsed metrics

Jump to

Keyboard shortcuts

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