Documentation
¶
Overview ¶
Package policy loads .go-code.yaml from a repo root and evaluates simple team rules against a review.DeltaResult.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ForbiddenImport ¶
ForbiddenImport blocks a specific import path (substring match).
type Policy ¶
type Policy struct {
Version int `yaml:"version"`
Severity string `yaml:"severity"` // warning | error
PathFilters Filters `yaml:"path_filters"`
Rules RuleSet `yaml:"rules"`
}
Policy is the parsed team policy.
func Load ¶
Load reads .go-code.yaml from root. Returns (nil, nil) when the file is absent — policy is opt-in.
func LoadWithDefaults ¶
LoadWithDefaults reads a server-wide defaults file (may be empty path), then overlays the repo-local .go-code.yaml on top. Repo rules take precedence on scalar fields; list fields (forbidden_imports, required_when_touching, path_filters) are concatenated. Returns nil only when both files are missing.
type RequiredWhen ¶
type RequiredWhen struct {
Path string `yaml:"path"`
MustAlsoTouch string `yaml:"must_also_touch"`
Reason string `yaml:"reason"`
}
RequiredWhen enforces that touching path X also touches path Y.
type RuleSet ¶
type RuleSet struct {
ForbiddenImports []ForbiddenImport `yaml:"forbidden_imports"`
RequiredWhen []RequiredWhen `yaml:"required_when_touching"`
MaxFuncLines int `yaml:"max_func_lines"`
NoMagicHTTPStatus bool `yaml:"no_magic_http_status"`
}
RuleSet is the set of supported rules. Keep this small and explicit — do not build a generic rule DSL.