detectors

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector interface {
	// Name returns the detector name
	Name() string

	// Detect analyzes a function and returns any issues found
	Detect(cfg *config.AnalysisConfig, file *parser.FileMetrics, fn *parser.FunctionMetrics, fset *token.FileSet, funcDecl *ast.FuncDecl) []*Issue

	// Enabled returns whether this detector is enabled
	Enabled(cfg *config.AnalysisConfig) bool
}

Detector defines the interface for anti-pattern detection

type DuplicateErrorDetector

type DuplicateErrorDetector struct{}

DuplicateErrorDetector detects repetitive error handling patterns

func NewDuplicateErrorDetector

func NewDuplicateErrorDetector() *DuplicateErrorDetector

NewDuplicateErrorDetector creates a new duplicate error detector

func (*DuplicateErrorDetector) Detect

Detect checks for repetitive error handling patterns

func (*DuplicateErrorDetector) Enabled

Enabled returns whether this detector is enabled

func (*DuplicateErrorDetector) Name

func (d *DuplicateErrorDetector) Name() string

Name returns the detector name

type Issue

type Issue struct {
	Severity  string `json:"severity"`  // "warning", "info", "error"
	Type      string `json:"type"`      // "large_file", "long_function", etc.
	File      string `json:"file"`      // File path
	Line      int    `json:"line"`      // Line number (0 if not applicable)
	Function  string `json:"function"`  // Function name (empty if not applicable)
	Message   string `json:"message"`   // Human-readable message
	Value     int    `json:"value"`     // Actual value (e.g., line count)
	Threshold int    `json:"threshold"` // Threshold value
}

Issue represents a code quality issue found during analysis

type MagicNumberDetector

type MagicNumberDetector struct{}

MagicNumberDetector detects magic numbers (numeric literals)

func NewMagicNumberDetector

func NewMagicNumberDetector() *MagicNumberDetector

NewMagicNumberDetector creates a new magic number detector

func (*MagicNumberDetector) Detect

Detect checks for magic numbers in a function

func (*MagicNumberDetector) Enabled

func (d *MagicNumberDetector) Enabled(cfg *config.AnalysisConfig) bool

Enabled returns whether this detector is enabled

func (*MagicNumberDetector) Name

func (d *MagicNumberDetector) Name() string

Name returns the detector name

type NestingDepthDetector

type NestingDepthDetector struct{}

NestingDepthDetector detects functions with excessive nesting

func NewNestingDepthDetector

func NewNestingDepthDetector() *NestingDepthDetector

NewNestingDepthDetector creates a new nesting depth detector

func (*NestingDepthDetector) Detect

Detect checks if a function has excessive nesting depth

func (*NestingDepthDetector) Enabled

Enabled returns whether this detector is enabled

func (*NestingDepthDetector) Name

func (d *NestingDepthDetector) Name() string

Name returns the detector name

type ParameterCountDetector

type ParameterCountDetector struct{}

ParameterCountDetector detects functions with too many parameters

func NewParameterCountDetector

func NewParameterCountDetector() *ParameterCountDetector

NewParameterCountDetector creates a new parameter count detector

func (*ParameterCountDetector) Detect

Detect checks if a function has too many parameters

func (*ParameterCountDetector) Enabled

Enabled returns whether this detector is enabled

func (*ParameterCountDetector) Name

func (d *ParameterCountDetector) Name() string

Name returns the detector name

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry manages all available detectors

func NewRegistry

func NewRegistry(cfg *config.AnalysisConfig) *Registry

NewRegistry creates a new detector registry with all detectors

func (*Registry) RunAll

func (r *Registry) RunAll(file *parser.FileMetrics, fn *parser.FunctionMetrics, fset *token.FileSet, funcDecl *ast.FuncDecl) []*Issue

RunAll runs all enabled detectors on a function

type ReturnCountDetector

type ReturnCountDetector struct{}

ReturnCountDetector detects functions with too many return statements

func NewReturnCountDetector

func NewReturnCountDetector() *ReturnCountDetector

NewReturnCountDetector creates a new return count detector

func (*ReturnCountDetector) Detect

Detect checks if a function has too many return statements

func (*ReturnCountDetector) Enabled

func (d *ReturnCountDetector) Enabled(cfg *config.AnalysisConfig) bool

Enabled returns whether this detector is enabled

func (*ReturnCountDetector) Name

func (d *ReturnCountDetector) Name() string

Name returns the detector name

Jump to

Keyboard shortcuts

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