Documentation
¶
Overview ¶
Package collectors provides signal extraction modules for stringer.
Package collectors provides signal extraction modules for stringer.
Package collectors provides signal extraction modules for stringer.
Index ¶
- Variables
- func ModuleFromPath(path string) string
- func ParseDuration(s string) (time.Duration, error)
- type APIDriftCollector
- type APIDriftMetrics
- type AuthorShare
- type ComplexityCollector
- type ComplexityMetrics
- type ConfigDriftCollector
- type ConfigDriftMetrics
- type CouplingCollector
- type CouplingMetrics
- type DeadCodeCollector
- type DeadCodeMetrics
- type DepHealthCollector
- type DepHealthMetrics
- type DirectoryOwnership
- type DirectoryTestRatio
- type DocStaleCollector
- type DocStaleMetrics
- type DuplicationCollector
- type DuplicationMetrics
- type FileChurn
- type FunctionComplexity
- type GitHubCollector
- type GitHygieneCollector
- type GitHygieneMetrics
- type GitlogCollector
- type GitlogMetrics
- type GoFuncInfo
- type LotteryRiskCollector
- type LotteryRiskMetrics
- type ModuleDep
- type ModuleReplace
- type ModuleRetract
- type PackageQuery
- type PatternsCollector
- type PatternsMetrics
- type SecretMatch
- type SecretPattern
- type TodoCollector
- type TodoMetrics
- type VulnCollector
- type VulnDetail
- type VulnEntry
- type VulnMetrics
Constants ¶
This section is empty.
Variables ¶
var FS testable.FileSystem = testable.DefaultFS
FS is the file system implementation used by this package. Override in tests with a testable.MockFileSystem.
Functions ¶
func ModuleFromPath ¶ added in v0.5.0
ModuleFromPath derives a module name from a file path by taking the first two path segments (e.g., "internal/collectors") or the directory name if only one level deep. Root-level files return ".".
Types ¶
type APIDriftCollector ¶ added in v1.3.0
type APIDriftCollector struct {
// contains filtered or unexported fields
}
APIDriftCollector detects drift between OpenAPI/Swagger specs and route handler registrations in code.
func (*APIDriftCollector) Collect ¶ added in v1.3.0
func (c *APIDriftCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks the repository to detect API contract drift between spec files and route handler registrations in code.
func (*APIDriftCollector) Metrics ¶ added in v1.3.0
func (c *APIDriftCollector) Metrics() any
Metrics returns structured metrics from the API drift scan.
func (*APIDriftCollector) Name ¶ added in v1.3.0
func (c *APIDriftCollector) Name() string
Name returns the collector name used for registration and filtering.
type APIDriftMetrics ¶ added in v1.3.0
type APIDriftMetrics struct {
SpecFilesFound int
RoutesInSpec int
RoutesInCode int
UndocumentedRoutes int
UnimplementedRoutes int
StaleVersionRoutes int
}
APIDriftMetrics holds structured metrics from the API drift scan.
type AuthorShare ¶ added in v0.5.0
type AuthorShare struct {
}
AuthorShare describes a single author's ownership share of a directory.
type ComplexityCollector ¶ added in v1.3.0
type ComplexityCollector struct {
// contains filtered or unexported fields
}
ComplexityCollector detects complex functions using regex-based function detection and control flow keyword counting. Produces scored signals for functions exceeding a configurable complexity threshold.
func (*ComplexityCollector) Collect ¶ added in v1.3.0
func (c *ComplexityCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks source files in repoPath, detects complex functions, and returns them as raw signals.
func (*ComplexityCollector) Metrics ¶ added in v1.3.0
func (c *ComplexityCollector) Metrics() any
Metrics returns structured metrics from the complexity scan.
func (*ComplexityCollector) Name ¶ added in v1.3.0
func (c *ComplexityCollector) Name() string
Name returns the collector name used for registration and filtering.
type ComplexityMetrics ¶ added in v1.3.0
type ComplexityMetrics struct {
Functions []FunctionComplexity // sorted by score desc
FilesAnalyzed int
FunctionsFound int
}
ComplexityMetrics holds structured metrics from the complexity scan.
type ConfigDriftCollector ¶ added in v1.3.0
type ConfigDriftCollector struct {
// contains filtered or unexported fields
}
ConfigDriftCollector detects configuration cruft and drift across ecosystems: env var references missing from templates, dead config keys, and inconsistent defaults across environment files.
func (*ConfigDriftCollector) Collect ¶ added in v1.3.0
func (c *ConfigDriftCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks the repository looking for env var drift, dead config keys, and inconsistent defaults across environment files.
func (*ConfigDriftCollector) Metrics ¶ added in v1.3.0
func (c *ConfigDriftCollector) Metrics() any
Metrics returns structured metrics from the config drift scan.
func (*ConfigDriftCollector) Name ¶ added in v1.3.0
func (c *ConfigDriftCollector) Name() string
Name returns the collector name used for registration and filtering.
type ConfigDriftMetrics ¶ added in v1.3.0
type ConfigDriftMetrics struct {
EnvTemplatesFound int
EnvVarsInCode int
EnvVarsInTemplates int
DriftSignals int
DeadKeySignals int
InconsistentSignals int
}
ConfigDriftMetrics holds structured metrics from the configuration drift scan.
type CouplingCollector ¶ added in v1.4.0
type CouplingCollector struct {
// contains filtered or unexported fields
}
CouplingCollector detects circular dependencies and high-coupling modules by building an import graph from source files and running Tarjan's SCC algorithm for cycle detection.
func (*CouplingCollector) Collect ¶ added in v1.4.0
func (c *CouplingCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks source files in repoPath, builds an import graph, detects circular dependencies and high-coupling modules, and returns them as signals.
func (*CouplingCollector) Metrics ¶ added in v1.4.0
func (c *CouplingCollector) Metrics() any
Metrics returns the structured metrics from the last scan.
func (*CouplingCollector) Name ¶ added in v1.4.0
func (c *CouplingCollector) Name() string
Name returns the collector name used for registration and filtering.
type CouplingMetrics ¶ added in v1.4.0
type CouplingMetrics struct {
FilesScanned int
ModulesFound int
CircularDeps int
HighCouplingCount int
SkippedCapExceeded bool
}
CouplingMetrics holds structured metrics from the coupling scan.
type DeadCodeCollector ¶ added in v1.3.0
type DeadCodeCollector struct {
// contains filtered or unexported fields
}
DeadCodeCollector detects unused functions and types using regex-based symbol extraction and in-memory reference searching. Follows the regex-over-AST philosophy from DR-013/DR-014.
func (*DeadCodeCollector) Collect ¶ added in v1.3.0
func (c *DeadCodeCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks source files, extracts symbol definitions, then searches for references to determine which symbols are dead code.
func (*DeadCodeCollector) Metrics ¶ added in v1.3.0
func (c *DeadCodeCollector) Metrics() any
Metrics returns structured metrics from the dead code scan.
func (*DeadCodeCollector) Name ¶ added in v1.3.0
func (c *DeadCodeCollector) Name() string
Name returns the collector name used for registration and filtering.
type DeadCodeMetrics ¶ added in v1.3.0
type DeadCodeMetrics struct {
FilesAnalyzed int
SymbolsFound int
DeadSymbols int
SkippedCapExceeded bool
}
DeadCodeMetrics holds structured metrics from the dead code scan.
type DepHealthCollector ¶ added in v0.6.0
type DepHealthCollector struct {
// contains filtered or unexported fields
}
DepHealthCollector parses dependency manifests (go.mod, package.json, Cargo.toml, pom.xml, *.csproj, requirements.txt, pyproject.toml) to extract dependency information and emits signals for deprecated, yanked, archived, and stale dependencies across multiple ecosystems.
func (*DepHealthCollector) Collect ¶ added in v0.6.0
func (c *DepHealthCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect parses dependency manifests in repoPath and returns signals for actionable findings (local replaces, retracted versions, archived repos, deprecated modules, yanked versions, stale dependencies) across Go, npm, Cargo, Maven, NuGet, and Python ecosystems.
func (*DepHealthCollector) Metrics ¶ added in v0.6.0
func (c *DepHealthCollector) Metrics() any
Metrics returns structured dependency data from the last Collect call.
func (*DepHealthCollector) Name ¶ added in v0.6.0
func (c *DepHealthCollector) Name() string
Name returns the collector name used for registration and filtering.
type DepHealthMetrics ¶ added in v0.6.0
type DepHealthMetrics struct {
ModulePath string
GoVersion string
Dependencies []ModuleDep
Replaces []ModuleReplace
Retracts []ModuleRetract
Archived []string
Deprecated []string
Stale []string
Yanked []string
Ecosystems []string // ecosystems detected (e.g., "go", "npm", "cargo")
}
DepHealthMetrics holds structured dependency data parsed from manifests.
type DirectoryOwnership ¶ added in v0.5.0
type DirectoryOwnership struct {
Path string
LotteryRisk int
Authors []AuthorShare
TotalLines int
}
DirectoryOwnership describes ownership distribution for a single directory.
type DirectoryTestRatio ¶ added in v0.5.0
DirectoryTestRatio describes the test coverage ratio for a directory.
type DocStaleCollector ¶ added in v1.3.0
type DocStaleCollector struct {
// contains filtered or unexported fields
}
DocStaleCollector detects stale documentation: docs that haven't been updated when their associated source code changed, and broken internal links within markdown files.
func (*DocStaleCollector) Collect ¶ added in v1.3.0
func (c *DocStaleCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks the repository looking for stale documentation, co-change drift, and broken internal links.
func (*DocStaleCollector) Metrics ¶ added in v1.3.0
func (c *DocStaleCollector) Metrics() any
Metrics returns structured metrics from the doc staleness scan.
func (*DocStaleCollector) Name ¶ added in v1.3.0
func (c *DocStaleCollector) Name() string
Name returns the collector name used for registration and filtering.
type DocStaleMetrics ¶ added in v1.3.0
DocStaleMetrics holds structured metrics from the doc staleness scan.
type DuplicationCollector ¶ added in v1.4.0
type DuplicationCollector struct {
// contains filtered or unexported fields
}
DuplicationCollector detects copy-paste code duplication using a token-based sliding window approach with FNV-64a hashing. It finds both exact duplicates (Type 1) and near-clones with renamed identifiers (Type 2).
func (*DuplicationCollector) Collect ¶ added in v1.4.0
func (c *DuplicationCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks source files in repoPath, detects duplicated code blocks, and returns them as raw signals.
func (*DuplicationCollector) Metrics ¶ added in v1.4.0
func (c *DuplicationCollector) Metrics() any
Metrics returns structured metrics from the duplication scan.
func (*DuplicationCollector) Name ¶ added in v1.4.0
func (c *DuplicationCollector) Name() string
Name returns the collector name used for registration and filtering.
type DuplicationMetrics ¶ added in v1.4.0
type DuplicationMetrics struct {
FilesScanned int
ExactClones int
NearClones int
DuplicatedLines int
}
DuplicationMetrics holds structured metrics from the duplication scan.
type FunctionComplexity ¶ added in v1.3.0
type FunctionComplexity struct {
FilePath string
FuncName string
StartLine int
EndLine int
Lines int
Branches int
Score float64 // lines/50 + branches (regex) or max(cyc/20, cog/30, nest/5) (AST)
Cyclomatic int // AST-based cyclomatic complexity (0 if regex-analyzed)
Cognitive int // AST-based cognitive complexity (0 if regex-analyzed)
MaxNesting int // AST-based max nesting depth (0 if regex-analyzed)
ASTBased bool // true if analyzed via Go AST, false if regex-based
}
FunctionComplexity holds complexity metrics for a single detected function.
type GitHubCollector ¶ added in v0.3.0
type GitHubCollector struct {
// GitOpener is the opener used to access the git repository.
// If nil, testable.DefaultGitOpener is used.
GitOpener testable.GitOpener
// contains filtered or unexported fields
}
GitHubCollector imports open issues, pull requests, and actionable review comments from GitHub.
func (*GitHubCollector) Collect ¶ added in v0.3.0
func (c *GitHubCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect fetches open issues, PRs, and review comments from GitHub and returns them as raw signals.
func (*GitHubCollector) Name ¶ added in v0.3.0
func (c *GitHubCollector) Name() string
Name returns the collector name used for registration and filtering.
type GitHygieneCollector ¶ added in v1.3.0
type GitHygieneCollector struct {
// contains filtered or unexported fields
}
GitHygieneCollector detects repository-level hygiene problems: large committed binaries, merge conflict markers, committed secrets, and mixed line endings.
func (*GitHygieneCollector) Collect ¶ added in v1.3.0
func (c *GitHygieneCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks the repository, performing four hygiene checks per file in a single pass: large binaries, merge conflict markers, committed secrets, and mixed line endings.
func (*GitHygieneCollector) Metrics ¶ added in v1.3.0
func (c *GitHygieneCollector) Metrics() any
Metrics returns structured metrics from the git hygiene scan.
func (*GitHygieneCollector) Name ¶ added in v1.3.0
func (c *GitHygieneCollector) Name() string
Name returns the collector name used for registration and filtering.
type GitHygieneMetrics ¶ added in v1.3.0
type GitHygieneMetrics struct {
FilesScanned int
LargeBinaries int
MergeConflictMarkers int
CommittedSecrets int
MixedLineEndings int
}
GitHygieneMetrics holds structured metrics from the git hygiene scan.
type GitlogCollector ¶
type GitlogCollector struct {
// GitOpener is the opener used to access the git repository.
// If nil, testable.DefaultGitOpener is used.
GitOpener testable.GitOpener
// contains filtered or unexported fields
}
GitlogCollector examines git history for reverts, high-churn files, and stale branches.
func (*GitlogCollector) Collect ¶
func (c *GitlogCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect scans the repository at repoPath for git-level signals.
func (*GitlogCollector) Metrics ¶ added in v0.5.0
func (c *GitlogCollector) Metrics() any
Metrics returns structured metrics from the git log analysis.
func (*GitlogCollector) Name ¶
func (c *GitlogCollector) Name() string
Name returns the collector name used for registration and filtering.
type GitlogMetrics ¶ added in v0.5.0
GitlogMetrics holds structured metrics from the git log analysis.
type GoFuncInfo ¶ added in v1.5.0
type GoFuncInfo struct {
Name string
Receiver string // empty for free functions, e.g. "(*Server)" for methods
StartLine int
EndLine int
Lines int // non-blank body lines
IsExported bool
Cyclomatic int // McCabe cyclomatic complexity
Cognitive int // SonarSource cognitive complexity
MaxNesting int // maximum nesting depth
}
GoFuncInfo holds analysis results for a single Go function.
type LotteryRiskCollector ¶ added in v0.3.0
type LotteryRiskCollector struct {
// contains filtered or unexported fields
}
LotteryRiskCollector analyzes git blame and commit history to identify directories with low lottery risk (single-author ownership risk).
func (*LotteryRiskCollector) Collect ¶ added in v0.3.0
func (c *LotteryRiskCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect scans the repository at repoPath for directories with low bus factor and returns them as raw signals.
func (*LotteryRiskCollector) Metrics ¶ added in v0.5.0
func (c *LotteryRiskCollector) Metrics() any
Metrics returns structured ownership data for all analyzed directories.
func (*LotteryRiskCollector) Name ¶ added in v0.3.0
func (c *LotteryRiskCollector) Name() string
Name returns the collector name used for registration and filtering.
type LotteryRiskMetrics ¶ added in v0.5.0
type LotteryRiskMetrics struct {
Directories []DirectoryOwnership
}
LotteryRiskMetrics holds structured metrics from the lottery risk analysis.
type ModuleReplace ¶ added in v0.6.0
type ModuleReplace struct {
OldPath string
OldVersion string
NewPath string
NewVersion string
IsLocal bool
}
ModuleReplace represents a single replace directive.
type ModuleRetract ¶ added in v0.6.0
ModuleRetract represents a single retract directive.
type PackageQuery ¶ added in v0.7.0
PackageQuery represents a single dependency to check for vulnerabilities.
type PatternsCollector ¶
type PatternsCollector struct {
// contains filtered or unexported fields
}
PatternsCollector detects structural code-quality patterns such as oversized files, missing tests, and low test-to-source ratios.
func (*PatternsCollector) Collect ¶
func (c *PatternsCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks source files in repoPath, detects pattern-based signals, and returns them as raw signals.
func (*PatternsCollector) Metrics ¶ added in v0.5.0
func (c *PatternsCollector) Metrics() any
Metrics returns structured metrics from the patterns analysis.
func (*PatternsCollector) Name ¶
func (c *PatternsCollector) Name() string
Name returns the collector name used for registration and filtering.
type PatternsMetrics ¶ added in v0.5.0
type PatternsMetrics struct {
LargeFiles int
DirectoryTestRatios []DirectoryTestRatio
}
PatternsMetrics holds structured metrics from the patterns analysis.
type SecretMatch ¶ added in v1.5.0
SecretMatch holds a match result from the registry.
type SecretPattern ¶ added in v1.5.0
type SecretPattern struct {
ID string // unique identifier e.g. "aws-access-key"
Name string // human-readable name
Pattern *regexp.Regexp // compiled regex
Confidence float64 // 0.0-1.0
Keywords []string // optional pre-filter keywords for performance
}
SecretPattern defines a single secret detection pattern.
type TodoCollector ¶
type TodoCollector struct {
// contains filtered or unexported fields
}
TodoCollector scans repository files for TODO, FIXME, HACK, XXX, BUG, and OPTIMIZE comments, enriches them with git blame data, and produces scored RawSignal values.
func (*TodoCollector) Collect ¶
func (c *TodoCollector) Collect(ctx context.Context, repoPath string, opts signal.CollectorOpts) ([]signal.RawSignal, error)
Collect walks source files in repoPath, extracts TODO-style comments, and returns them as raw signals with confidence scores and blame attribution.
func (*TodoCollector) Metrics ¶ added in v0.5.0
func (c *TodoCollector) Metrics() any
Metrics returns structured metrics from the TODO scan.
func (*TodoCollector) Name ¶
func (c *TodoCollector) Name() string
Name returns the collector name used for registration and filtering.
type TodoMetrics ¶ added in v0.5.0
TodoMetrics holds structured metrics from the TODO scan.
type VulnCollector ¶ added in v0.7.0
type VulnCollector struct {
// contains filtered or unexported fields
}
VulnCollector detects known vulnerabilities in Go module dependencies using the OSV.dev API.
func (*VulnCollector) Collect ¶ added in v0.7.0
func (c *VulnCollector) Collect(ctx context.Context, repoPath string, _ signal.CollectorOpts) ([]signal.RawSignal, error)
Collect parses dependency manifests (go.mod, pom.xml, build.gradle/kts, Cargo.toml, *.csproj, requirements.txt, pyproject.toml, package.json) in repoPath, queries OSV.dev for known vulnerabilities, and returns signals with severity-based confidence scoring.
func (*VulnCollector) Metrics ¶ added in v0.7.0
func (c *VulnCollector) Metrics() any
Metrics returns structured vulnerability data from the last Collect call.
func (*VulnCollector) Name ¶ added in v0.7.0
func (c *VulnCollector) Name() string
Name returns the collector name used for registration and filtering.
type VulnDetail ¶ added in v0.7.0
type VulnDetail struct {
ID string
Aliases []string
Summary string
Ecosystem string
PackageName string
Version string
FixedVersion string
Severity string // CVSS v3 score string, or ""
}
VulnDetail holds processed vulnerability information from OSV.dev.
type VulnEntry ¶ added in v0.7.0
type VulnEntry struct {
OSVID string
CVE string
Module string
Version string
FixedVersion string
Summary string
Severity string
Ecosystem string
FilePath string
}
VulnEntry represents a single vulnerability finding.
type VulnMetrics ¶ added in v0.7.0
VulnMetrics holds structured vulnerability data from the last scan.
Source Files
¶
- apidrift.go
- complexity.go
- complexity_go.go
- configdrift.go
- coupling.go
- coupling_graph.go
- deadcode.go
- dephealth.go
- dephealth_crates.go
- dephealth_deprecated.go
- dephealth_github.go
- dephealth_maven.go
- dephealth_npm.go
- dephealth_nuget.go
- dephealth_pypi.go
- docstale.go
- duplication.go
- duplication_hash.go
- duration.go
- github.go
- githubclient.go
- githygiene.go
- gitlog.go
- lotteryrisk.go
- lotteryrisk_ownership.go
- lotteryrisk_reviews.go
- patterns.go
- patterns_classify.go
- patterns_testlookup.go
- secrets.go
- symlink.go
- todos.go
- vuln.go
- vuln_gradle.go
- vuln_maven.go
- vuln_npm.go
- vuln_nuget.go
- vuln_osv.go
- vuln_python.go
- vuln_rust.go