Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSchema ¶
func GenerateSchema(metas []RuleMeta) *jsonschema.Schema
GenerateSchema produces the krit.yml JSON Schema as a typed *jsonschema.Schema. The result implements json.Marshaler, so callers that emit JSON can hand it directly to json.NewEncoder.Encode or json.MarshalIndent.
func KnownOptionsByRule ¶
func KnownOptionsByRule() map[string]map[string]OptionType
KnownOptionsByRule returns a map of rule name -> set of allowed config keys. Always includes "active" and "excludes" as standard keys. Option keys are read from each rule's Meta() descriptor via rules.MetaForRule.
func KnownRuleSets ¶
KnownRuleSets returns the set of known ruleset names from the registry.
func KnownRulesBySet ¶
KnownRulesBySet returns a map of ruleset -> set of rule names.
Types ¶
type OptionMeta ¶
type OptionMeta struct {
Name string
Type string // "int", "bool", "string", "string[]", "regex"
Default interface{}
Description string
}
OptionMeta describes one configurable option of a rule.
type OptionType ¶
type OptionType int
OptionType represents the expected type of a config option.
const ( OptionTypeBool OptionType = iota OptionTypeInt OptionTypeString OptionTypeStringSlice OptionTypeRegex )
type RuleMeta ¶
type RuleMeta struct {
Name string
Description string
RuleSet string
Active bool // default active state
Fixable bool
FixLevel string // cosmetic/idiomatic/semantic or ""
LanguageSupport map[string]api.LanguageSupport
Options []OptionMeta
}
RuleMeta describes a rule's configurable options for schema generation.
func CollectRuleMeta ¶
func CollectRuleMeta() []RuleMeta
CollectRuleMeta walks api.Registry and builds metadata for every rule, reading configurable options from each rule's Meta() descriptor via rules.MetaForRule (which falls back to the metaByName index for adapter-wrapped rules that drop the concrete struct pointer).
type ValidationError ¶
type ValidationError struct {
Path string // e.g. "style.MagicNumber.ignoreNumbers"
Message string
Level string // "error" or "warning"
}
ValidationError describes a single config validation problem.
func ValidateConfig ¶
func ValidateConfig(cfg *config.Config) []ValidationError
ValidateConfig checks a Config for unknown rulesets, unknown rules, unknown config keys, and type mismatches. It returns a slice of errors/warnings.
func (ValidationError) String ¶
func (e ValidationError) String() string