Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalysisInput ¶
type AnalysisInput struct {
ProjectID string // Project identifier
ParseResult *parser.ParseResult // Complete parse result with type information
}
AnalysisInput contains the input data for analysis
type AnalysisReport ¶
type AnalysisReport struct {
ProjectID string // Project identifier
Timestamp int64 // Analysis timestamp
DependencyGraph *DependencyGraph // Project dependencies
InterfaceImplementations []*parser.Implementation // Interface implementations from parser
CallChains []*CallChain // Function call relationships
CircularDependencies []*CircularDependency // Circular import cycles
Metrics *CodeMetrics // Code quality metrics
}
AnalysisReport contains comprehensive analysis results
type Analyzer ¶
type Analyzer interface {
// AnalyzeProject performs comprehensive analysis on parsed project data
AnalyzeProject(ctx context.Context, input *AnalysisInput) (*AnalysisReport, error)
// BuildDependencyGraph constructs a dependency graph from parsed packages
BuildDependencyGraph(ctx context.Context, packages []*parser.PackageInfo) (*DependencyGraph, error)
// MapCallChains traces function call relationships using proper type information
MapCallChains(ctx context.Context, packages []*parser.PackageInfo) ([]*CallChain, error)
// DetectCircularDependencies identifies circular import cycles
DetectCircularDependencies(ctx context.Context, graph *DependencyGraph) ([]*CircularDependency, error)
}
Analyzer defines the contract for code analysis operations
func NewAnalyzer ¶
NewAnalyzer creates a new analyzer service
type CallChain ¶
type CallChain struct {
Caller *FunctionReference // The calling function
Callee *FunctionReference // The called function
CallSites []CallSite // Where the calls occur
IsRecursive bool // Whether this is a recursive call
}
CallChain represents a function call relationship
type CallSite ¶
type CallSite struct {
File string // File path
Line int // Line number
Column int // Column position
Expression string // Call expression
}
CallSite represents a specific location where a function is called
type CircularDependency ¶
type CircularDependency struct {
Cycle []string // Ordered list of paths forming the cycle
Severity SeverityLevel // Impact severity
Impact []string // Affected components
}
CircularDependency represents a circular import cycle
type CodeMetrics ¶
type CodeMetrics struct {
TotalFiles int // Total number of files
TotalLines int // Total lines of code
TotalFunctions int // Total number of functions
TotalInterfaces int // Total number of interfaces
TotalStructs int // Total number of structs
CyclomaticComplexity map[string]int // Function complexity scores
TestCoverage float64 // Percentage of code covered by tests
DependencyDepth int // Maximum dependency chain length
CouplingScore float64 // Inter-package coupling metric
}
CodeMetrics contains code quality measurements
type Config ¶
type Config struct {
MaxDependencyDepth int // Maximum allowed dependency depth
IgnoreTestFiles bool // Skip test file analysis
IgnoreVendor bool // Skip vendor directory
IncludeMetrics bool // Calculate code metrics
ParallelWorkers int // Number of concurrent workers
}
Config holds analyzer configuration
func DefaultAnalyzerConfig ¶
func DefaultAnalyzerConfig() *Config
DefaultAnalyzerConfig returns default analyzer configuration
type DependencyEdge ¶
type DependencyEdge struct {
From string // Source path
To string // Target path
Type DependencyType // Import type
Line int // Line number of import
}
DependencyEdge represents a dependency relationship
type DependencyGraph ¶
type DependencyGraph struct {
Nodes map[string]*DependencyNode // Map of package path to node
Edges []*DependencyEdge // All dependency relationships
Root string // Project root path
}
DependencyGraph represents the project's dependency structure
type DependencyNode ¶
type DependencyNode struct {
Path string // File or package path
Type NodeType // File or Package
Dependencies []string // Paths of direct dependencies
Dependents []string // Paths that depend on this node
}
DependencyNode represents a file or package in the dependency graph
type DependencyType ¶
type DependencyType string
DependencyType specifies the type of dependency
const ( DependencyTypeImport DependencyType = "import" DependencyTypeEmbed DependencyType = "embed" DependencyTypeInterface DependencyType = "interface" DependencyTypeContains DependencyType = "contains" )
type FunctionReference ¶
type FunctionReference struct {
Name string // Function name
Package string // Package name
Receiver string // Receiver type if method
Signature string // Full signature
}
FunctionReference represents a reference to a function
type SeverityLevel ¶
type SeverityLevel string
SeverityLevel indicates the severity of an issue
const ( SeverityLow SeverityLevel = "low" SeverityMedium SeverityLevel = "medium" SeverityHigh SeverityLevel = "high" )