config

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileTooLarge = errors.New("file exceeds maximum size limit")

ErrFileTooLarge is returned when a file exceeds the configured size limit.

Functions

func IsFileTooLarge

func IsFileTooLarge(size int64, maxSize int64) bool

IsFileTooLarge checks if a file exceeds the configured maximum size. Returns true if the file is too large, false otherwise. If maxSize is 0, no limit is enforced.

Types

type AnalysisConfig

type AnalysisConfig struct {
	Complexity  bool  `koanf:"complexity"`
	SATD        bool  `koanf:"satd"`
	DeadCode    bool  `koanf:"dead_code"`
	Churn       bool  `koanf:"churn"`
	Duplicates  bool  `koanf:"duplicates"`
	Defect      bool  `koanf:"defect"`
	TDG         bool  `koanf:"tdg"`
	Graph       bool  `koanf:"graph"`
	LintHotspot bool  `koanf:"lint_hotspot"`
	Context     bool  `koanf:"context"`
	ChurnDays   int   `koanf:"churn_days"`
	MaxFileSize int64 `koanf:"max_file_size"` // Maximum file size in bytes (0 = no limit)
}

AnalysisConfig controls which analyzers run.

type CacheConfig

type CacheConfig struct {
	Enabled bool   `koanf:"enabled"`
	Dir     string `koanf:"dir"`
	TTL     int    `koanf:"ttl"` // TTL in hours
}

CacheConfig controls caching behavior.

type Config

type Config struct {
	// Analysis settings
	Analysis AnalysisConfig `koanf:"analysis"`

	// Thresholds for various metrics
	Thresholds ThresholdConfig `koanf:"thresholds"`

	// Duplicate detection settings
	Duplicates DuplicateConfig `koanf:"duplicates"`

	// File exclusion patterns
	Exclude ExcludeConfig `koanf:"exclude"`

	// Cache settings
	Cache CacheConfig `koanf:"cache"`

	// Output settings
	Output OutputConfig `koanf:"output"`
}

Config holds all configuration options for omen.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a config with sensible defaults.

func Load

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

Load loads configuration from a file.

func LoadOrDefault

func LoadOrDefault() *Config

LoadOrDefault tries to load config from standard locations or returns defaults.

func (*Config) ShouldExclude

func (c *Config) ShouldExclude(path string) bool

ShouldExclude checks if a path should be excluded from analysis.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that all config values are within acceptable ranges. Returns an error describing any validation failures.

type DuplicateConfig

type DuplicateConfig struct {
	MinTokens            int     `koanf:"min_tokens"`
	SimilarityThreshold  float64 `koanf:"similarity_threshold"`
	ShingleSize          int     `koanf:"shingle_size"`
	NumHashFunctions     int     `koanf:"num_hash_functions"`
	NumBands             int     `koanf:"num_bands"`
	RowsPerBand          int     `koanf:"rows_per_band"`
	NormalizeIdentifiers bool    `koanf:"normalize_identifiers"`
	NormalizeLiterals    bool    `koanf:"normalize_literals"`
	IgnoreComments       bool    `koanf:"ignore_comments"`
	MinGroupSize         int     `koanf:"min_group_size"`
}

DuplicateConfig defines duplicate detection settings (pmat-compatible).

type ExcludeConfig

type ExcludeConfig struct {
	Patterns   []string `koanf:"patterns"`
	Extensions []string `koanf:"extensions"`
	Dirs       []string `koanf:"dirs"`
	Gitignore  bool     `koanf:"gitignore"`
}

ExcludeConfig defines file exclusion patterns.

type OutputConfig

type OutputConfig struct {
	Format  string `koanf:"format"` // text, json, markdown
	Color   bool   `koanf:"color"`
	Verbose bool   `koanf:"verbose"`
}

OutputConfig controls output formatting.

type ThresholdConfig

type ThresholdConfig struct {
	CyclomaticComplexity int     `koanf:"cyclomatic_complexity"`
	CognitiveComplexity  int     `koanf:"cognitive_complexity"`
	DuplicateMinLines    int     `koanf:"duplicate_min_lines"`
	DuplicateSimilarity  float64 `koanf:"duplicate_similarity"`
	DeadCodeConfidence   float64 `koanf:"dead_code_confidence"`
	DefectHighRisk       float64 `koanf:"defect_high_risk"`
	TDGHighRisk          float64 `koanf:"tdg_high_risk"`
}

ThresholdConfig defines metric thresholds.

Jump to

Keyboard shortcuts

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