Documentation
¶
Index ¶
- func AnalyzeFile(filepath string) ([]string, error)
- func CalculateCommentDensity(fileContent string, comments []*ast.CommentGroup) float64
- func CalculateCyclomaticComplexity(n ast.Node) int
- func CalculateHalsteadVolume(src string) float64
- func CalculateLOC(src string) int
- func CalculateMaintainabilityIndex(cyclomatic int, halsteadVolume float64, loc int, commentDensity float64, ...) float64
- type MethodResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeFile ¶
AnalyzeFile analyzes a Go source file and returns its functions and methods
func CalculateCommentDensity ¶
func CalculateCommentDensity(fileContent string, comments []*ast.CommentGroup) float64
CalculateCommentDensity computes the ratio of comment lines to total lines in the file.
func CalculateCyclomaticComplexity ¶
CalculateCyclomaticComplexity calculates the cyclomatic complexity for a given AST node.
func CalculateHalsteadVolume ¶
CalculateHalsteadVolume computes a simplified Halstead Volume based on operator and operand counts.
func CalculateLOC ¶
CalculateLOC returns the number of lines in the source code.
func CalculateMaintainabilityIndex ¶
func CalculateMaintainabilityIndex(cyclomatic int, halsteadVolume float64, loc int, commentDensity float64, commentDensityMultiplier float64) float64
CalculateMaintainabilityIndex computes the Maintainability Index (MI) using a standard formula and a bonus from comment density.
Types ¶
type MethodResult ¶
type MethodResult struct {
MethodName string
Cyclomatic int
HalsteadVolume float64
LOC int
MaintainabilityIndex float64
}
MethodResult holds the analysis results for each function.
func AnalyzeMethods ¶
func AnalyzeMethods(filePath string, commentDensityMultiplier float64) ([]MethodResult, float64, error)
AnalyzeMethods analyzes all functions in a given Go source file and computes code quality metrics. It returns the analysis results for each function and the global comment density.