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

types

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisResult

type AnalysisResult struct {
	Name     string                     // Name of the analysis (e.g., "complexity")
	Category string                     // Category identifier (e.g., "C1", "C3", "C6")
	Metrics  map[string]CategoryMetrics // Analysis metrics
}

AnalysisResult holds the output of a single analysis pass (Phase 2).

type AnalysisTarget

type AnalysisTarget struct {
	Language Language
	RootDir  string       // Project root directory
	Files    []SourceFile // Source files for this language
}

AnalysisTarget is the language-agnostic unit of analysis. Each target represents one language found in the project.

type C1Metrics

type C1Metrics struct {
	CyclomaticComplexity MetricSummary
	FunctionLength       MetricSummary
	FileSize             MetricSummary
	LargeFilePct         float64        // percentage of files > 500 LOC
	AfferentCoupling     map[string]int // pkg path -> incoming dep count
	EfferentCoupling     map[string]int // pkg path -> outgoing dep count
	DuplicationRate      float64        // percentage 0-100
	DuplicatedBlocks     []DuplicateBlock
	Functions            []FunctionMetric // per-function detail
}

C1Metrics holds Code Health metric results.

func (*C1Metrics) IsCategoryMetrics

func (*C1Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C1Metrics as a CategoryMetrics implementation.

type C2LanguageMetrics

type C2LanguageMetrics struct {
	TypeAnnotationCoverage float64 // % of functions/params with type annotations (0-100)
	NamingConsistency      float64 // % of identifiers following convention (0-100)
	MagicNumberRatio       float64 // magic numbers per 1000 LOC
	TypeStrictness         float64 // 0 or 1: strict mode on/off (Python mypy, TS strict)
	NullSafety             float64 // % of pointer/nullable usages with safety checks (0-100)
	TotalFunctions         int     // total functions analyzed
	TotalIdentifiers       int     // total identifiers checked for naming
	MagicNumberCount       int     // raw count of magic numbers
	LOC                    int     // lines of code for this language
	// Unavailable tracks metrics not applicable for this language.
	// Keyed by metric name (e.g., "null_safety"). Unavailable metrics are
	// excluded from the weighted average during scoring.
	Unavailable map[string]bool
}

C2LanguageMetrics holds C2 metrics for a single language.

type C2Metrics

type C2Metrics struct {
	PerLanguage map[Language]*C2LanguageMetrics
	Aggregate   *C2LanguageMetrics // LOC-weighted aggregate
}

C2Metrics holds Semantic Explicitness metric results.

func (*C2Metrics) IsCategoryMetrics

func (*C2Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C2Metrics as a CategoryMetrics implementation.

type C3Metrics

type C3Metrics struct {
	MaxDirectoryDepth int
	AvgDirectoryDepth float64
	ModuleFanout      MetricSummary // avg refs per module
	CircularDeps      [][]string    // each cycle as list of package paths
	ImportComplexity  MetricSummary // avg relative path segments
	DeadExports       []DeadExport  // unreferenced exported symbols
}

C3Metrics holds Architectural Navigability metric results.

func (*C3Metrics) IsCategoryMetrics

func (*C3Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C3Metrics as a CategoryMetrics implementation.

type C4Metrics

type C4Metrics struct {
	Available           bool
	ReadmePresent       bool
	ReadmeWordCount     int
	CommentDensity      float64 // % lines with comments (0-100)
	APIDocCoverage      float64 // % public APIs with docstrings (0-100)
	ChangelogPresent    bool
	ChangelogDaysOld    int // -1 if not present
	DiagramsPresent     bool
	ExamplesPresent     bool
	ContributingPresent bool
	// Counts for verbose output
	TotalSourceLines int
	CommentLines     int
	PublicAPIs       int
	DocumentedAPIs   int

	// LLM-based metrics (only populated if --enable-c4-llm is used)
	LLMEnabled        bool    // true if LLM analysis was performed
	ReadmeClarity     int     // 1-10 scale
	ExampleQuality    int     // 1-10 scale
	Completeness      int     // 1-10 scale
	CrossRefCoherence int     // 1-10 scale
	LLMCostUSD        float64 // Actual cost incurred
	LLMTokensUsed     int     // Total tokens used
	LLMFilesSampled   int     // Number of files sampled for LLM analysis
}

C4Metrics holds Documentation Quality metric results.

func (*C4Metrics) IsCategoryMetrics

func (*C4Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C4Metrics as a CategoryMetrics implementation.

type C5Metrics

type C5Metrics struct {
	Available            bool
	ChurnRate            float64       // avg lines changed per commit (90-day window)
	TemporalCouplingPct  float64       // % of file pairs with >70% co-change rate
	AuthorFragmentation  float64       // avg distinct authors per file (90-day window)
	CommitStability      float64       // median days between changes per file
	HotspotConcentration float64       // % of total changes in top 10% of files
	TopHotspots          []FileChurn   // top churning files (up to 10)
	CoupledPairs         []CoupledPair // detected temporal couplings
	TotalCommits         int
	TimeWindowDays       int
	RepoStalenessMonths  float64 // months since HEAD commit (wall-clock staleness)
}

C5Metrics holds Temporal & Operational Dynamics metric results.

func (*C5Metrics) IsCategoryMetrics

func (*C5Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C5Metrics as a CategoryMetrics implementation.

type C6Metrics

type C6Metrics struct {
	TestFileCount    int
	SourceFileCount  int
	TestToCodeRatio  float64       // test LOC / source LOC
	CoveragePercent  float64       // -1 if not available
	CoverageSource   string        // "go-cover", "lcov", "cobertura", "none"
	TestIsolation    float64       // percentage of tests without external deps
	AssertionDensity MetricSummary // assertions per test function
	TestFunctions    []TestFunctionMetric
}

C6Metrics holds Testing Infrastructure metric results.

func (*C6Metrics) IsCategoryMetrics

func (*C6Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C6Metrics as a CategoryMetrics implementation.

type C7DebugSample

type C7DebugSample struct {
	FilePath    string       `json:"file_path"`
	Description string       `json:"description"`
	Prompt      string       `json:"prompt"`
	Response    string       `json:"response"`
	Score       int          `json:"score"`
	Duration    float64      `json:"duration_seconds"`
	ScoreTrace  C7ScoreTrace `json:"score_trace"`
	Error       string       `json:"error,omitempty"`
}

C7DebugSample holds complete debug data for one metric sample evaluation. Only populated when debug mode is active.

type C7IndicatorMatch

type C7IndicatorMatch struct {
	Name    string `json:"name"`    // e.g., "positive:returns", "negative:unclear"
	Matched bool   `json:"matched"` // Whether the indicator was found
	Delta   int    `json:"delta"`   // Point contribution (+1, -1, +2, etc.)
}

C7IndicatorMatch records one heuristic indicator check during scoring.

type C7MetricResult

type C7MetricResult struct {
	MetricID     string          // e.g., "task_execution_consistency"
	MetricName   string          // e.g., "Task Execution Consistency"
	Score        int             // 1-10
	Status       string          // completed, timeout, error
	Duration     float64         // seconds
	Reasoning    string          // scoring rationale
	Samples      []string        // sample descriptions used
	DebugSamples []C7DebugSample `json:"debug_samples,omitempty"` // only present when debug active
}

C7MetricResult holds results for a single MECE metric.

type C7Metrics

type C7Metrics struct {
	Available bool // false if claude CLI not found or user declined

	// Legacy 4-task scores (0-100 scale) - preserved for backward compatibility
	IntentClarity          int // 0-100 score
	ModificationConfidence int // 0-100 score
	CrossFileCoherence     int // 0-100 score
	SemanticCompleteness   int // 0-100 score

	// NEW: 5 MECE metrics (1-10 scale)
	TaskExecutionConsistency       int // M1: Reproducibility across runs (1-10)
	CodeBehaviorComprehension      int // M2: Understanding what code does (1-10)
	CrossFileNavigation            int // M3: Tracing dependencies across files (1-10)
	IdentifierInterpretability     int // M4: Inferring meaning from names (1-10)
	DocumentationAccuracyDetection int // M5: Detecting comment/code mismatches (1-10)

	// Aggregate scores
	OverallScore float64 // Legacy: average of 4 task scores (0-100)
	MECEScore    float64 // NEW: weighted average of 5 MECE metrics (1-10)

	// Detailed results
	TaskResults   []C7TaskResult   // Legacy task results
	MetricResults []C7MetricResult // NEW: MECE metric results

	// Execution metadata
	TotalDuration float64 // seconds
	TokensUsed    int     // estimated total tokens
	CostUSD       float64 // estimated cost
}

C7Metrics holds Agent Evaluation metric results including 5 MECE metrics.

func (*C7Metrics) IsCategoryMetrics

func (*C7Metrics) IsCategoryMetrics()

IsCategoryMetrics marks C7Metrics as a CategoryMetrics implementation.

type C7ScoreTrace

type C7ScoreTrace struct {
	BaseScore  int                `json:"base_score"`  // Starting score before adjustments
	Indicators []C7IndicatorMatch `json:"indicators"`  // Each indicator checked
	FinalScore int                `json:"final_score"` // Score after clamping to 1-10
}

C7ScoreTrace records the complete scoring breakdown for one sample.

type C7TaskResult

type C7TaskResult struct {
	TaskID    string  // e.g., "intent_clarity"
	TaskName  string  // e.g., "Intent Clarity"
	Score     int     // 0-100
	Status    string  // completed, timeout, error
	Duration  float64 // seconds
	Reasoning string  // scoring rationale from LLM judge
}

C7TaskResult holds results for a single C7 evaluation task.

type CategoryMetrics

type CategoryMetrics interface {
	IsCategoryMetrics()
}

CategoryMetrics is a marker interface for category metric structs stored in AnalysisResult.Metrics. Using a typed interface instead of interface{} improves null safety metrics and enforces type safety.

type CategoryScore

type CategoryScore struct {
	Name      string     // Category identifier (e.g., "C1")
	Score     float64    // Weighted average of sub-scores (1-10)
	Weight    float64    // Weight in composite score
	SubScores []SubScore // Per-metric sub-scores
}

CategoryScore holds the score for one category (e.g., C1 Code Health).

type CoupledPair

type CoupledPair struct {
	FileA         string
	FileB         string
	Coupling      float64 // 0-100 percentage
	SharedCommits int
}

CoupledPair holds a pair of files with temporal coupling.

type DeadExport

type DeadExport struct {
	Package string
	Name    string
	File    string
	Line    int
	Kind    string // "func", "type", "var", "const"
}

DeadExport represents an exported symbol not referenced within the module.

type DiscoveredFile

type DiscoveredFile struct {
	Path          string    // Absolute path to the file
	RelPath       string    // Path relative to project root
	Class         FileClass // Classification of the file
	ExcludeReason string    // Why file was excluded (empty if not excluded)
	Language      Language  // Programming language of the file
}

DiscoveredFile represents a file found during directory scanning.

type DuplicateBlock

type DuplicateBlock struct {
	FileA     string
	StartA    int
	EndA      int
	FileB     string
	StartB    int
	EndB      int
	LineCount int
}

DuplicateBlock represents a detected code clone.

type EvidenceItem

type EvidenceItem struct {
	FilePath    string  `json:"file_path"`
	Line        int     `json:"line"`
	Value       float64 `json:"value"`
	Description string  `json:"description"`
}

EvidenceItem represents a single worst-offender for a metric.

type ExitError

type ExitError struct {
	Code    int
	Message string
}

ExitError is returned when the CLI should exit with a specific code. For example, threshold violations exit with code 2.

func (*ExitError) Error

func (e *ExitError) Error() string

Error implements the error interface.

type FileChurn

type FileChurn struct {
	Path         string
	TotalChanges int
	CommitCount  int
	AuthorCount  int
}

FileChurn holds churn data for a single file.

type FileClass

type FileClass int

FileClass categorizes discovered files in a Go project.

const (
	ClassSource    FileClass = iota // Regular Go source file
	ClassTest                       // Test file (*_test.go)
	ClassGenerated                  // Generated file (has code generation comment)
	ClassExcluded                   // Excluded file (vendor, .gitignore, etc.)
)

func (FileClass) String

func (fc FileClass) String() string

String returns the human-readable name for a FileClass.

type FunctionMetric

type FunctionMetric struct {
	Package    string
	Name       string
	File       string
	Line       int
	Complexity int
	LineCount  int
}

FunctionMetric holds per-function analysis data.

type Language

type Language string

Language identifies the programming language of source files.

const (
	LangGo         Language = "go"
	LangPython     Language = "python"
	LangTypeScript Language = "typescript"
)

type MetricSummary

type MetricSummary struct {
	Avg       float64
	Max       int
	MaxEntity string // which function/file has the max
}

MetricSummary holds avg/max for a numeric metric.

type RepoMetadata added in v0.0.8

type RepoMetadata struct {
	Available         bool                 // false if not a git repo
	LinesOfCode       int                  // total source LOC (excluding tests, generated, vendor)
	FirstCommitDate   time.Time            // date of the first commit
	LastCommitDate    time.Time            // date of the most recent commit
	ContributorCount  int                  // number of unique contributors
	TotalCommits      int                  // total number of commits
	LanguageBreakdown map[Language]float64 // language -> percentage of source LOC
}

RepoMetadata holds high-level repository metadata for quick understanding of a repo's state and maturity. These are informational metrics (not scored).

type ScanResult

type ScanResult struct {
	RootDir        string           // Absolute path to project root
	TotalFiles     int              // Total files discovered
	SourceCount    int              // Number of source files
	TestCount      int              // Number of test files
	GeneratedCount int              // Number of generated files
	VendorCount    int              // Number of vendor-excluded files
	GitignoreCount int              // Number of gitignore-excluded files
	SkippedCount   int              // Files/dirs skipped due to errors (permission denied, broken paths, etc.)
	SymlinkCount   int              // Symlinks detected and skipped
	Files          []DiscoveredFile // All discovered files
	PerLanguage    map[Language]int // Source file count per language
}

ScanResult holds the output of the file discovery phase.

type ScoredResult

type ScoredResult struct {
	ProjectName string          // Name of the scanned project (basename of root dir)
	Categories  []CategoryScore // Per-category scores (C1, C3, C6)
	Composite   float64         // Weighted composite score (1-10)
	Tier        string          // Tier classification (e.g., "Agent-Ready")
}

ScoredResult holds the complete scoring output for a project.

type SourceFile

type SourceFile struct {
	Path     string
	RelPath  string
	Language Language
	Lines    int
	Content  []byte    // Raw source content (needed for Tree-sitter)
	Class    FileClass // source, test, generated, excluded
}

SourceFile represents a single source file for analysis.

type SubScore

type SubScore struct {
	MetricName string         `json:"metric_name"`
	RawValue   float64        `json:"raw_value"`
	Score      float64        `json:"score"`
	Weight     float64        `json:"weight"`
	Available  bool           `json:"available"`
	Evidence   []EvidenceItem `json:"evidence"`
}

SubScore holds the score for a single metric within a category.

type TestFunctionMetric

type TestFunctionMetric struct {
	Package        string
	Name           string
	File           string
	Line           int
	AssertionCount int
	HasExternalDep bool
}

TestFunctionMetric holds per-test-function data.

Jump to

Keyboard shortcuts

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