Documentation
¶
Overview ¶
Package detection provides multi-method code duplication detection.
This package coordinates multiple detection algorithms and combines their results to provide comprehensive duplicate reporting.
Detection Methods Supported: - DetectionMethodArtDupl: Suffix tree algorithm on AST tokens - DetectionMethodHash: Rolling hash on file content - DetectionMethodTodos: Find TODO/FIXME/HACK comments - DetectionMethodLegacy: Find deprecated functions and legacy patterns
Core Types: - MultiDetector: Coordinates multiple detection methods - MethodDetector: Interface for individual detection algorithms
Usage:
cfg := config.DetectionConfig{Methods: methods, Verbose: verbose}
md := detection.NewMultiDetector(cfg, data, tree)
matches := md.FindDuplOver(threshold)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LegacyDetector ¶
type LegacyDetector struct {
// contains filtered or unexported fields
}
LegacyDetector finds legacy code patterns.
func NewLegacyDetector ¶
func NewLegacyDetector() *LegacyDetector
NewLegacyDetector creates a new legacy detector with default patterns.
func (*LegacyDetector) FindLegacy ¶
func (ld *LegacyDetector) FindLegacy(data []*syntax.Node) <-chan syntax.Match
FindLegacy finds all legacy patterns in provided nodes.
type LegacyIssue ¶
type LegacyIssue struct {
Filename domain.Filepath `json:"filename"`
Line domain.LineNumber `json:"line"`
Type string `json:"type"`
Message string `json:"message"`
Severity domain.CloneSeverity `json:"severity"`
}
LegacyIssue represents a legacy code pattern.
func (LegacyIssue) GetLine ¶
func (l LegacyIssue) GetLine() domain.LineNumber
GetLine returns the line number for this issue (implements LineExtractor interface).
type LegacyPattern ¶
type LegacyPattern struct {
Type string `json:"type"`
Message string `json:"message"`
Severity string `json:"severity"`
Functions []string `json:"functions,omitempty"`
Patterns []string `json:"patterns,omitempty"`
Imports []string `json:"imports,omitempty"`
}
LegacyPattern represents a pattern to detect legacy code.
type LineExtractor ¶
type LineExtractor interface {
GetLine() domain.LineNumber
}
LineExtractor is an interface for issue types that have a line number.
type MethodDetector ¶
type MethodDetector interface {
// FindDuplOver runs detection with the given threshold and returns
// matches via a channel for streaming consumption.
FindDuplOver(threshold int) <-chan syntax.Match
}
MethodDetector is the interface that all detection algorithms implement. Each detector produces a stream of syntax.Match results for duplicate code.
type MultiDetector ¶
type MultiDetector struct {
// contains filtered or unexported fields
}
MultiDetector runs multiple detection methods and combines results.
func NewMultiDetector ¶
func NewMultiDetector( cfg config.DetectionConfig, data []*syntax.Node, tree *suffixtree.STree, ) *MultiDetector
NewMultiDetector creates a new multi-method detector.
func (*MultiDetector) FindDuplOver ¶
func (md *MultiDetector) FindDuplOver(threshold int) <-chan syntax.Match
FindDuplOver runs all configured detection methods.
type TodoDetector ¶
type TodoDetector struct {
// contains filtered or unexported fields
}
TodoDetector finds TODO comments in Go source code.
func NewTodoDetector ¶
func NewTodoDetector() *TodoDetector
NewTodoDetector creates a new TODO detector.
type TodoIssue ¶
type TodoIssue struct {
Filename domain.Filepath `json:"filename"`
Line domain.LineNumber `json:"line"`
Text string `json:"text"`
Type string `json:"type"`
Tags []string `json:"tags,omitempty"`
}
TodoIssue represents a TODO comment found in code.
func (TodoIssue) GetLine ¶
func (t TodoIssue) GetLine() domain.LineNumber
GetLine returns the line number for this issue (implements LineExtractor interface).