cbo

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssessRisk

func AssessRisk(cbo int, config Config) domain.RiskLevel

AssessRisk determines the risk level based on the CBO count and config thresholds.

func MatchesPattern

func MatchesPattern(name string, patterns []string) bool

MatchesPattern checks if a name matches any of the given wildcard patterns. Patterns support '*' as a wildcard using filepath.Match semantics.

Types

type ClassDependency

type ClassDependency struct {
	ClassName string
	Kind      DependencyKind
}

ClassDependency represents a single dependency from one class to another.

type ClassInfo

type ClassInfo struct {
	Name         string
	FilePath     string
	StartLine    int
	EndLine      int
	Dependencies []ClassDependency
	IsAbstract   bool
	BaseClasses  []string
	Methods      []string
	Attributes   []string
}

ClassInfo holds the information about a class needed for CBO computation. Language-specific analyzers populate this from their AST.

type Config

type Config struct {
	LowThreshold    int
	MediumThreshold int
	ExcludePatterns []string
}

Config holds configuration for CBO analysis.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default CBO configuration.

type DependencyKind

type DependencyKind int

DependencyKind represents the type of dependency between classes.

const (
	DepInheritance     DependencyKind = iota // Class inheritance
	DepTypeHint                              // Type hint/annotation
	DepInstantiation                         // Object instantiation
	DepAttributeAccess                       // Attribute access on another class
	DepImport                                // Import dependency
)

func (DependencyKind) String

func (k DependencyKind) String() string

String returns the string representation of a DependencyKind.

type Result

type Result struct {
	ClassName           string
	FilePath            string
	StartLine           int
	EndLine             int
	CouplingCount       int
	DependencyBreakdown map[DependencyKind]int
	DependentClasses    []string
	RiskLevel           domain.RiskLevel
	IsAbstract          bool
}

Result holds the CBO analysis result for a single class.

func ComputeCBO

func ComputeCBO(classes []*ClassInfo, config Config) []*Result

ComputeCBO computes Coupling Between Objects for each class.

Jump to

Keyboard shortcuts

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