collectors

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 29 Imported by: 0

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

Constants

This section is empty.

Variables

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

func ModuleFromPath(path string) string

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 ".".

func ParseDuration added in v0.5.0

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses duration strings like "90d", "6m", "1y" into time.Duration. Supported units: d (days), w (weeks), m (months/30d), y (years/365d).

Types

type AuthorShare added in v0.5.0

type AuthorShare struct {
	Name      string
	Ownership float64
}

AuthorShare describes a single author's ownership share of a directory.

type DepHealthCollector added in v0.6.0

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

DepHealthCollector parses go.mod to extract dependency information and emits signals for local replace directives, retracted versions, archived repos, deprecated modules, and stale dependencies.

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 the go.mod file in repoPath and returns signals for actionable findings (local replaces, retracted versions, archived repos, deprecated modules, stale dependencies).

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
}

DepHealthMetrics holds structured dependency data parsed from go.mod.

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

type DirectoryTestRatio struct {
	Path        string
	SourceFiles int
	TestFiles   int
	Ratio       float64
}

DirectoryTestRatio describes the test coverage ratio for a directory.

type FileChurn added in v0.5.0

type FileChurn struct {
	Path        string
	ChangeCount int
	AuthorCount int
}

FileChurn describes change frequency for a single file.

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 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

type GitlogMetrics struct {
	FileChurns       []FileChurn
	RevertCount      int
	StaleBranchCount int
}

GitlogMetrics holds structured metrics from the git log analysis.

type LotteryRiskCollector added in v0.3.0

type LotteryRiskCollector 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
}

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 ModuleDep added in v0.6.0

type ModuleDep struct {
	Path     string
	Version  string
	Indirect bool
}

ModuleDep represents a single require directive.

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

type ModuleRetract struct {
	Low       string
	High      string
	Rationale string
}

ModuleRetract represents a single retract directive.

type PackageQuery added in v0.7.0

type PackageQuery struct {
	Ecosystem string
	Name      string
	Version   string
}

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 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

type TodoMetrics struct {
	Total         int
	ByKind        map[string]int
	WithTimestamp int
}

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 govulncheck engine.

func (*VulnCollector) Collect added in v0.7.0

func (c *VulnCollector) Collect(ctx context.Context, repoPath string, _ signal.CollectorOpts) ([]signal.RawSignal, error)

Collect runs govulncheck on the repository at repoPath and returns signals for each known vulnerability in the module's dependencies.

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
}

VulnEntry represents a single vulnerability finding.

type VulnMetrics added in v0.7.0

type VulnMetrics struct {
	TotalVulns int
	Vulns      []VulnEntry
}

VulnMetrics holds structured vulnerability data from the last scan.

Jump to

Keyboard shortcuts

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