Documentation
¶
Index ¶
- Variables
- func FindDefaultConfig() string
- type Config
- func (c *Config) Data() map[string]interface{}
- func (c *Config) GetBool(ruleSet, rule, key string, defaultVal bool) bool
- func (c *Config) GetInt(ruleSet, rule, key string, defaultVal int) int
- func (c *Config) GetString(ruleSet, rule, key string, defaultVal string) string
- func (c *Config) GetStringList(ruleSet, rule, key string) []string
- func (c *Config) GetTopLevelBool(key string, defaultVal bool) bool
- func (c *Config) GetTopLevelInt(section, key string, defaultVal int) int
- func (c *Config) GetTopLevelList(key string) []string
- func (c *Config) GetTopLevelString(section, key, defaultVal string) string
- func (c *Config) GetTopLevelStringList(section, key string) []string
- func (c *Config) Has(ruleSet, rule, key string) bool
- func (c *Config) IsRuleActive(ruleSet, rule string) *bool
- func (c *Config) IsRuleSetActive(ruleSet string) *bool
- func (c *Config) ModuleTemplate() ModuleTemplateConfig
- func (c *Config) SLOs() []SLOConfig
- func (c *Config) Set(ruleSet, rule, key string, value interface{})
- func (c *Config) TestSourcePaths() []string
- func (c *Config) TestSourcePathsOverride() []string
- type EditorConfig
- type ModuleTemplateConfig
- type SLOConfig
Constants ¶
This section is empty.
Variables ¶
var Filenames = []string{"krit.yml", ".krit.yml"}
Filenames lists the krit configuration filenames, in the order callers should probe for them. Centralised so adding a third name (e.g. krit.yaml) is a one-line change.
Functions ¶
func FindDefaultConfig ¶
func FindDefaultConfig() string
FindDefaultConfig locates the default config file. It checks relative to the executable path first, then the current directory.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds the parsed YAML configuration for krit rules. The data structure is: ruleSet -> ruleName -> key -> value
func LoadAndMerge ¶
LoadAndMerge loads defaults first, then merges user config on top. If userPath is empty, auto-detection is used for the user config. If no user config is found, defaults alone are returned.
func LoadConfig ¶
LoadConfig loads a YAML config file and returns a Config. If path is empty, it auto-detects krit.yml or .krit.yml from the project root, falling back to config/default-krit.yml relative to the executable.
func (*Config) Data ¶
Data returns the underlying config data map for serialization (e.g., cache hashing).
func (*Config) GetBool ¶
GetBool returns a bool config value for a rule, or defaultVal if not found.
func (*Config) GetInt ¶
GetInt returns an integer config value for a rule, or defaultVal if not found.
func (*Config) GetString ¶
GetString returns a string config value for a rule, or defaultVal if not found.
func (*Config) GetStringList ¶
GetStringList returns a string slice config value for a rule. Returns nil if not found.
func (*Config) GetTopLevelBool ¶
GetTopLevelBool returns a bool value from a top-level config key. For example, GetTopLevelBool("warningsAsErrors", false) reads config.warningsAsErrors.
func (*Config) GetTopLevelInt ¶
GetTopLevelInt returns an int value nested under a top-level section. For example, GetTopLevelInt("parseCache", "maxSizeMB", 200) reads parseCache.maxSizeMB.
func (*Config) GetTopLevelList ¶
func (*Config) GetTopLevelString ¶
GetTopLevelString returns a string value from a top-level config section. For example, GetTopLevelString("android", "enabled", "auto") reads android.enabled.
func (*Config) GetTopLevelStringList ¶
GetTopLevelStringList returns a string slice from a top-level section.
func (*Config) Has ¶
Has reports whether a given rule config key is set in the YAML (i.e. the key exists under ruleSet.rule in the config map). Used by the registry- driven ApplyConfig path to distinguish "key absent" from "key set to the zero value" — GetInt/GetString/GetBool all return the default when the key is missing, which is the same shape they return when a legitimate override happens to equal the default. HasKey on ConfigSource is the contract that lets descriptor Apply closures know whether to mutate the rule struct.
func (*Config) IsRuleActive ¶
IsRuleActive returns whether a rule is active in the config. Returns nil if the rule is not mentioned in config (caller should use default).
func (*Config) IsRuleSetActive ¶
IsRuleSetActive returns whether an entire ruleset is active. Returns nil if not specified.
func (*Config) ModuleTemplate ¶
func (c *Config) ModuleTemplate() ModuleTemplateConfig
ModuleTemplate returns the configured feature-module template, if any.
func (*Config) TestSourcePaths ¶
func (*Config) TestSourcePathsOverride ¶
type EditorConfig ¶
type EditorConfig struct {
MaxLineLength int // max_line_length (0 = not set, -1 = off)
IndentSize int // indent_size (0 = not set)
TabWidth int // tab_width (0 = not set)
IndentStyle string // "space" or "tab" or ""
Charset string // charset or ""
InsertFinalNewline *bool // insert_final_newline (nil = not set)
TrimTrailingWhitespace *bool // trim_trailing_whitespace (nil = not set)
}
EditorConfig holds parsed .editorconfig properties relevant to krit. Only reads standard properties that affect analysis rules. Does NOT read ktlint_*, ij_kotlin_*, or ktfmt_* properties.
func LoadEditorConfig ¶
func LoadEditorConfig(startPath string) *EditorConfig
LoadEditorConfig walks up the directory tree from startPath looking for .editorconfig files. Merges properties from all found files (closest wins). Stops at a file with root = true.
func (*EditorConfig) ApplyToConfig ¶
func (ec *EditorConfig) ApplyToConfig(cfg *Config)
ApplyEditorConfigToRules updates rule configuration based on .editorconfig values. Called after YAML config is loaded — .editorconfig values override YAML for the properties it covers (matching ktfmt's behavior).
type ModuleTemplateConfig ¶
type ModuleTemplateConfig struct {
FeatureRoot string
RequiredSubmodules []string
RequiredPlugins []string
}
ModuleTemplateConfig describes the optional top-level module_template block.