lcom

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssessRisk

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

AssessRisk determines the risk level based on LCOM4 and config thresholds.

Types

type Config

type Config struct {
	LowThreshold    int
	MediumThreshold int
}

Config holds configuration for LCOM analysis.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default LCOM configuration.

type MethodAccess

type MethodAccess struct {
	MethodName   string
	InstanceVars map[string]bool
	Calls        map[string]bool
}

MethodAccess describes a method, which instance variables it accesses, and which sibling methods it calls (intra-class calls, e.g. self.helper()).

type Result

type Result struct {
	ClassName         string
	FilePath          string
	StartLine         int
	EndLine           int
	LCOM4             int
	TotalMethods      int
	ExcludedMethods   int
	InstanceVariables []string
	MethodGroups      [][]string
	RiskLevel         domain.RiskLevel
}

Result holds the LCOM4 analysis result for a class.

func ComputeLCOM4

func ComputeLCOM4(methods []MethodAccess, config Config) *Result

ComputeLCOM4 computes the LCOM4 metric using the Union-Find algorithm. LCOM4 counts the number of connected components among methods, where two methods are connected if they share at least one instance variable or one calls the other (intra-class method calls).

Jump to

Keyboard shortcuts

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