Documentation
¶
Overview ¶
Package config handles .stringer.yaml configuration files.
Index ¶
- Constants
- func FlattenMap(m map[string]any, prefix string) map[string]any
- func GetValue(cfg *Config, keyPath string) (any, error)
- func GlobalConfigDir() string
- func GlobalConfigPath() string
- func LoadRaw(path string) (map[string]any, error)
- func Merge(fileCfg *Config, cliCfg signal.ScanConfig) signal.ScanConfig
- func SetValue(data map[string]any, keyPath string, rawValue string) error
- func Validate(cfg *Config) error
- func ValidateKeyPath(keyPath string) error
- func Write(w io.Writer, cfg *Config) error
- func WriteFile(path string, data map[string]any) error
- type CollectorConfig
- type Config
- type PriorityOverrideConfig
Constants ¶
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
FlattenMap recursively flattens a nested map to dot-notation keys.
func GetValue ¶ added in v0.9.0
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
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
SetValue sets a value in a raw YAML map by dot-notation key path, creating intermediate maps as needed.
func ValidateKeyPath ¶ added in v0.9.0
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.
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 ¶
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
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.