Documentation
¶
Overview ¶
Package metrics provides static code quality metrics such as cyclomatic complexity.
Package metrics provides analysis of code quality metrics such as dead code detection.
Package metrics provides analysis of code duplication between functions.
Package metrics provides analysis of code quality metrics such as global state usage.
Package metrics provides analysis of code quality metrics such as function and file size.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComplexityResult ¶
type ComplexityResult struct {
Name string // Function name
File string // File path
Line int // Line number
Complexity int // Computed cyclomatic complexity
Exported bool // Whether function is exported
}
ComplexityResult represents the cyclomatic complexity of a single function.
func AnalyzeCyclomaticComplexity ¶
func AnalyzeCyclomaticComplexity(files []string) ([]ComplexityResult, error)
AnalyzeCyclomaticComplexity calculates complexity for all functions in given files.
type DeadFunction ¶
type DeadFunction struct {
Name string // Fully-qualified function name
Pos string // File and line number
Recv string // Receiver type (for methods)
PkgPath string // Package where the function is defined
IsExport bool // Whether the function is exported
}
DeadFunction represents a function or method that is never used.
func AnalyzeDeadCode ¶
func AnalyzeDeadCode(pattern string) ([]DeadFunction, error)
AnalyzeDeadCode analyzes all packages for unused (dead) functions.
type DuplicateBlock ¶
type DuplicateBlock struct {
Hash string // Hash of normalized function body
Funcs []DupFn // All functions that share this body
}
DuplicateBlock represents two or more identical function bodies across files.
func AnalyzeDuplicatedFunctions ¶
func AnalyzeDuplicatedFunctions(files []string) ([]DuplicateBlock, error)
AnalyzeDuplicatedFunctions scans a list of Go files and reports duplicated function bodies.
type FileSize ¶
FileSize stores metrics about a file's total lines of code.
func AnalyzeFileSizes ¶
AnalyzeFileSizes returns line counts for each provided Go source file.
type FunctionSize ¶
type FunctionSize struct {
Name string // Function name
LOC int // Lines of code
File string // File path
Line int // Line number where the function starts
Exported bool // Whether function is exported
}
FunctionSize stores metrics about a function's line length.
func AnalyzeFunctionSizes ¶
func AnalyzeFunctionSizes(files []string) ([]FunctionSize, error)
AnalyzeFunctionSizes parses Go files and returns a list of function sizes.
type GlobalSymbol ¶
type GlobalSymbol struct {
Name string // Symbol name
Kind string // "var" or "const"
PkgPath string // Full import path of the package
File string // File where symbol is defined
Line int // Line number
Exported bool // Whether the symbol is exported
Mutable bool // Whether the symbol is a variable (mutable)
HasInit bool // Whether the symbol has an initializer
}
GlobalSymbol represents a global variable or constant in a package.
func AnalyzeGlobals ¶
func AnalyzeGlobals(pattern string) ([]GlobalSymbol, error)
AnalyzeGlobals detects global variables and constants defined at package scope.