Documentation
¶
Index ¶
- func FindConfigDir(dir string) string
- func Get() (string, error)
- func IsExcluded(filePath string, excludePats []string, configDir string) bool
- func LoadExcludedFiles(dir string) []string
- func LoadProjectThresholds(dir, lang string) parser.Thresholds
- func Path() string
- func Save(c *Config) error
- func Set(key, value string) (string, error)
- type Config
- type ExcludeSection
- type ProjectConfig
- type RuleBranches
- type RuleBump
- type RuleFloat
- type RuleInt
- type RuleLine
- type RuleLoc
- type RulesInfo
- type RulesSection
- type UserConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindConfigDir ¶ added in v0.9.0
FindConfigDir walks upward from dir to find the directory containing .ailinter.toml.
func IsExcluded ¶ added in v0.9.0
IsExcluded checks if a file path (relative to configDir) matches any exclude pattern. Patterns ending in "/" match directory prefixes; other patterns match exact paths.
func LoadExcludedFiles ¶ added in v0.9.0
LoadExcludedFiles returns the list of excluded file/directory patterns from .ailinter.toml, walking upward from dir. Returns nil if no config or no exclude section.
func LoadProjectThresholds ¶
func LoadProjectThresholds(dir, lang string) parser.Thresholds
LoadProjectThresholds walks from dir upward to find .ailinter.toml, loads the defaults for the language, then merges user overrides.
Types ¶
type Config ¶
type Config struct {
AccessToken string `json:"access_token,omitempty"`
OnPremURL string `json:"onprem_url,omitempty"`
DefaultPath string `json:"default_path,omitempty"`
EnabledTools []string `json:"enabled_tools,omitempty"`
ReadOnly bool `json:"read_only,omitempty"`
Language string `json:"language,omitempty"`
RepoPath string `json:"repo_path,omitempty"`
Thresholds map[string]int `json:"thresholds,omitempty"`
DisableGit bool `json:"disable_git,omitempty"`
Project *ProjectConfig `json:"project,omitempty"`
}
Config represents ailinter's persistent configuration.
type ExcludeSection ¶ added in v0.9.0
type ExcludeSection struct {
Files []string `toml:"files"`
}
ExcludeSection holds file/directory exclusion patterns.
type ProjectConfig ¶
type ProjectConfig struct {
Path string `json:"path,omitempty"`
Extends string `json:"extends,omitempty"`
Rules RulesInfo `json:"rules,omitempty"`
}
ProjectConfig holds the project-level .ailinter.toml configuration.
func LoadProjectConfigFile ¶
func LoadProjectConfigFile(cwd string) *ProjectConfig
type RuleBranches ¶
type RuleBranches struct {
Weight float64 `toml:"weight"`
BranchesWarning int `toml:"branches_warning"`
BranchesAlert int `toml:"branches_alert"`
}
RuleBranches handles complex_conditional thresholds.
type RuleBump ¶
type RuleBump struct {
Weight float64 `toml:"weight"`
BumpsWarning int `toml:"bumps_warning"`
BumpDepth int `toml:"bump_depth"`
}
RuleBump handles Bumpy Road thresholds.
type RuleFloat ¶
type RuleFloat struct {
MinLines int `toml:"min_lines"`
MinSimilarity float64 `toml:"min_similarity"`
}
RuleFloat handles thresholds with float/similarity values.
type RuleInt ¶
type RuleInt struct {
Weight float64 `toml:"weight"`
Warning int `toml:"warning"`
Alert int `toml:"alert"`
}
RuleInt handles thresholds with warning/alert levels.
type RuleLine ¶
type RuleLine struct {
Warning int `toml:"warning"`
Min int `toml:"min_lines"`
Max int `toml:"max_consecutive"`
Ratio float64 `toml:"ratio"`
}
RuleLine handles thresholds with a single line-count threshold.
type RuleLoc ¶
type RuleLoc struct {
Weight float64 `toml:"weight"`
WarningLines int `toml:"warning_lines"`
AlertLines int `toml:"alert_lines"`
}
RuleLoc handles thresholds with LOC-based warning_lines/alert_lines.
type RulesInfo ¶
type RulesInfo struct {
DeepNesting *int `json:"deep_nesting_warning,omitempty"`
BrainMethod *int `json:"brain_method_warning_lines,omitempty"`
FileBloat *int `json:"file_bloat_warning_lines,omitempty"`
CyclomaticComplexity *int `json:"cyclomatic_complexity_warning,omitempty"`
BumpyRoad *int `json:"bumpy_road_bumps_warning,omitempty"`
LongParameterList *int `json:"long_parameter_list_warning,omitempty"`
ComplexConditional *int `json:"complex_conditional_branches_warning,omitempty"`
LongSwitch *int `json:"long_switch_warning,omitempty"`
ExcessiveComments *float64 `json:"excessive_comments_ratio,omitempty"`
}
RulesInfo holds readable rule overrides from .ailinter.toml.
type RulesSection ¶
type RulesSection struct {
DeepNesting *RuleInt `toml:"deep_nesting"`
BrainMethod *RuleLoc `toml:"brain_method"`
FileBloat *RuleLoc `toml:"file_bloat"`
ComplexConditional *RuleBranches `toml:"complex_conditional"`
CyclomaticComplexity *RuleInt `toml:"cyclomatic_complexity"`
BumpyRoad *RuleBump `toml:"bumpy_road"`
LongParameterList *RuleInt `toml:"long_parameter_list"`
LazyElement *RuleLine `toml:"lazy_element"`
ParagraphOfCode *RuleLine `toml:"paragraph_of_code"`
MessageChains *RuleLine `toml:"message_chains"`
PrimitiveObsession *RuleLine `toml:"primitive_obsession"`
ExcessiveComments *RuleLine `toml:"excessive_comments"`
GlobalData *RuleLine `toml:"global_data"`
LongScopeVariable *RuleLine `toml:"long_scope_variable"`
DuplicatedCode *RuleFloat `toml:"duplicated_code"`
LongSwitch *RuleInt `toml:"long_switch"`
}
RulesSection holds per-detector overrides.
type UserConfig ¶
type UserConfig struct {
Extends string `toml:"extends"`
Rules RulesSection `toml:"rules"`
Exclude ExcludeSection `toml:"exclude"`
}
UserConfig mirrors .ailinter.toml structure.