Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchesIgnoreExport ¶
MatchesIgnoreExport checks if a symbol name matches any ignore export pattern.
Types ¶
type Analyzer ¶
type Analyzer interface {
Name() string
Description() string
Analyze(project *Project, cfg *Config) (*Result, error)
}
Analyzer is the interface all analyzers implement.
type Config ¶
type Config struct {
IgnorePatterns []string `json:"ignore_patterns"`
IncludeTests bool `json:"include_tests"`
Rules map[string]Severity `json:"rules"`
CyclomaticThreshold int `json:"cyclomatic_threshold"`
CognitiveThreshold int `json:"cognitive_threshold"`
MinDuplicateLines int `json:"min_duplicate_lines"`
MinDuplicateTokens int `json:"min_duplicate_tokens"`
ArchitectureLayers []LayerConfig `json:"architecture_layers"`
IgnoreExports []string `json:"ignore_exports"`
GodPackageThreshold int `json:"god_package_threshold"`
}
Config holds all configuration for analyzer execution.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with sensible defaults.
type Finding ¶
type Finding struct {
Rule string `json:"rule"`
Category Category `json:"category"`
Severity Severity `json:"severity"`
Message string `json:"message"`
Location Location `json:"location"`
RelatedLocations []Location `json:"related_locations,omitempty"`
Meta map[string]any `json:"meta,omitempty"`
}
Finding represents a single issue found by an analyzer.
type LayerConfig ¶
type LayerConfig struct {
Name string `json:"name"`
Packages []string `json:"packages"`
CanImport []string `json:"can_import"`
}
LayerConfig defines an architecture layer for violation checking.
type Location ¶
type Location struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column,omitempty"`
EndLine int `json:"end_line,omitempty"`
}
Location identifies a position in source code.
type PackageInfo ¶
type PackageInfo struct {
ImportPath string
RelPath string
Name string
Dir string
Files []*ast.File
FilePaths []string
}
PackageInfo groups files belonging to the same Go package.
type Project ¶
type Project struct {
RootDir string
ModulePath string
Fset *token.FileSet
Packages map[string]*PackageInfo
Files map[string]*ast.File
GoModDeps []GoModDep
}
Project holds all parsed data for the Go module being analyzed.
type Report ¶
type Report struct {
Version string `json:"version"`
Timestamp string `json:"timestamp"`
RootDir string `json:"root_dir"`
TotalDuration string `json:"total_duration"`
Summary ReportSummary `json:"summary"`
Results []*Result `json:"results"`
}
Report is the aggregate output of all analyzers.
type ReportSummary ¶
type ReportSummary struct {
TotalFindings int `json:"total_findings"`
BySeverity map[Severity]int `json:"by_severity"`
ByCategory map[Category]int `json:"by_category"`
}
ReportSummary holds aggregate counts for a report.
type Result ¶
type Result struct {
Analyzer string `json:"analyzer"`
Duration time.Duration `json:"-"`
DurationMs int64 `json:"duration_ms"`
Findings []*Finding `json:"findings"`
Stats map[string]any `json:"stats,omitempty"`
}
Result is the output of a single analyzer run.