config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config handles .stringer.yaml configuration files.

Index

Constants

View Source
const FileName = ".stringer.yaml"

FileName is the expected config file name in a repository root.

Variables

This section is empty.

Functions

func FlattenMap added in v0.9.0

func FlattenMap(m map[string]any, prefix string) map[string]any

FlattenMap recursively flattens a nested map to dot-notation keys.

func GetValue added in v0.9.0

func GetValue(cfg *Config, keyPath string) (any, error)

GetValue retrieves a value from a Config by dot-notation key path. It returns scalar values as-is, and maps/slices for intermediate nodes.

func GlobalConfigDir added in v0.9.0

func GlobalConfigDir() string

GlobalConfigDir returns the directory for global stringer configuration. It uses $XDG_CONFIG_HOME/stringer if set, otherwise ~/.config/stringer.

func GlobalConfigPath added in v0.9.0

func GlobalConfigPath() string

GlobalConfigPath returns the path to the global config file.

func LoadRaw added in v0.9.0

func LoadRaw(path string) (map[string]any, error)

LoadRaw reads a YAML file as a raw map[string]any. If the file does not exist, it returns an empty map and nil error.

func Merge

func Merge(fileCfg *Config, cliCfg signal.ScanConfig) signal.ScanConfig

Merge combines file-based config with CLI-provided ScanConfig. CLI values take precedence; zero-value CLI fields fall through to file config.

func SetValue added in v0.9.0

func SetValue(data map[string]any, keyPath string, rawValue string) error

SetValue sets a value in a raw YAML map by dot-notation key path, creating intermediate maps as needed.

func Validate

func Validate(cfg *Config) error

Validate checks all fields in the config and returns all errors at once.

func ValidateKeyPath added in v0.9.0

func ValidateKeyPath(keyPath string) error

ValidateKeyPath checks that a dot-notation key path corresponds to a valid Config field. It uses yaml struct tags to build the valid key set.

func Write

func Write(w io.Writer, cfg *Config) error

Write marshals the config to YAML and writes it to w.

func WriteFile added in v0.9.0

func WriteFile(path string, data map[string]any) error

WriteFile marshals a raw map to YAML and writes it to the given path, creating parent directories as needed.

Types

type CollectorConfig

type CollectorConfig struct {
	Enabled         *bool    `yaml:"enabled,omitempty"`
	ErrorMode       string   `yaml:"error_mode,omitempty"`
	MinConfidence   float64  `yaml:"min_confidence,omitempty"`
	IncludePatterns []string `yaml:"include_patterns,omitempty"`
	ExcludePatterns []string `yaml:"exclude_patterns,omitempty"`

	// Lottery risk collector settings.
	LotteryRiskThreshold int `yaml:"lottery_risk_threshold,omitempty"`
	DirectoryDepth       int `yaml:"directory_depth,omitempty"`
	MaxBlameFiles        int `yaml:"max_blame_files,omitempty"`

	// Patterns collector settings.
	LargeFileThreshold int `yaml:"large_file_threshold,omitempty"`

	// Git collector settings.
	GitDepth int    `yaml:"git_depth,omitempty"`
	GitSince string `yaml:"git_since,omitempty"`

	// GitHub collector settings.
	IncludePRs            *bool  `yaml:"include_prs,omitempty"`
	CommentDepth          int    `yaml:"comment_depth,omitempty"`
	MaxIssuesPerCollector int    `yaml:"max_issues_per_collector,omitempty"`
	IncludeClosed         *bool  `yaml:"include_closed,omitempty"`
	HistoryDepth          string `yaml:"history_depth,omitempty"`

	// Anonymization settings.
	Anonymize string `yaml:"anonymize,omitempty"`

	// IncludeDemoPaths disables demo-path filtering for noise-prone signals.
	IncludeDemoPaths *bool `yaml:"include_demo_paths,omitempty"`

	// Timeout is the per-collector timeout (e.g. "60s", "2m").
	Timeout string `yaml:"timeout,omitempty"`
}

CollectorConfig holds per-collector settings in the config file.

type Config

type Config struct {
	OutputFormat      string                     `yaml:"output_format,omitempty"`
	MaxIssues         int                        `yaml:"max_issues,omitempty"`
	NoLLM             bool                       `yaml:"no_llm,omitempty"`
	BeadsAware        *bool                      `yaml:"beads_aware,omitempty"`
	Collectors        map[string]CollectorConfig `yaml:"collectors,omitempty"`
	PriorityOverrides []PriorityOverrideConfig   `yaml:"priority_overrides,omitempty"`
}

Config represents the contents of a .stringer.yaml file.

func Load

func Load(repoPath string) (*Config, error)

Load reads the .stringer.yaml file from the given repository root. If the file does not exist, it returns a zero-value Config and nil error.

func LoadGlobal added in v0.9.0

func LoadGlobal() (*Config, error)

LoadGlobal loads the global config file. If the file does not exist, it returns a zero-value Config and nil error.

type PriorityOverrideConfig added in v0.9.0

type PriorityOverrideConfig struct {
	Pattern  string `yaml:"pattern"`
	Priority int    `yaml:"priority"`
}

PriorityOverrideConfig maps a file-path glob pattern to a fixed priority.

Jump to

Keyboard shortcuts

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