lint

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package lint detects breaking changes between two versions of pbflags proto definitions.

Index

Constants

View Source
const (
	RuleTypeChanged  = "type_changed"
	RuleLayerChanged = "layer_changed"
)

Rule names.

View Source
const (
	RuleScopeDimChanged     = "scope_dimension_changed"
	RuleScopeRemoved        = "scope_removed"
	RuleFeatureScopeRemoved = "feature_scope_removed"
	RuleCondScopeCompat     = "condition_scope_compat"
)

Rule names for scope-related violations.

Variables

This section is empty.

Functions

func BuildDescriptors

func BuildDescriptors(protoDir string) ([]byte, error)

BuildDescriptors builds a FileDescriptorSet from the proto files in protoDir (working tree). Returns the serialized bytes.

func BuildDescriptorsFromRef

func BuildDescriptorsFromRef(protoDir, gitRef string) ([]byte, error)

BuildDescriptorsFromRef builds a FileDescriptorSet from the proto files at the given git ref. Extracts the proto directory from the ref into a temp directory, then runs buf build.

func ExtractScopesFromDescriptors added in v0.17.0

func ExtractScopesFromDescriptors(descriptorData []byte) ([]ScopeInfo, []FeatureScopeInfo, error)

ExtractScopesFromDescriptors builds ScopeInfo and FeatureScopeInfo from raw descriptors using contextutil's discovery functions and evaluator's FlagDef parsing.

func HasProtoChanges

func HasProtoChanges(baseRef, protoDir string) (bool, error)

HasProtoChanges returns true if any .proto files in protoDir differ between the given git ref and the working tree.

Types

type FeatureScopeInfo added in v0.17.0

type FeatureScopeInfo struct {
	FeatureID string
	Scopes    []string
}

FeatureScopeInfo holds a feature's scope declarations for comparison.

type ScopeInfo added in v0.17.0

type ScopeInfo struct {
	Name       string
	Dimensions []string // additional dimensions beyond globally required
}

ScopeInfo holds a scope's name and dimensions for comparison.

type Violation

type Violation struct {
	FlagID   string // e.g., "notifications/1"
	Rule     string // machine-readable rule name
	Message  string // human-readable description
	Guidance string // suggested fix
}

Violation represents a breaking change detected between two versions of flag definitions.

func Check

func Check(base, current []evaluator.FlagDef) []Violation

Check compares base and current flag definitions and returns any breaking change violations. This is a pure function with no I/O.

func CheckConditionScopeCompat added in v0.17.0

func CheckConditionScopeCompat(
	contextMsg protoreflect.MessageDescriptor,
	scopes []ScopeInfo,
	features []FeatureScopeInfo,
	flagDefs []evaluator.FlagDef,
	conditionDims map[string][]string,
) []Violation

CheckConditionScopeCompat checks that every CEL dimension referenced by a feature's conditions is available in every scope the feature declares. This uses the condition ASTs and scope definitions from the current descriptors.

func CheckScopes added in v0.17.0

func CheckScopes(baseScopes, currentScopes []ScopeInfo, baseFeatures, currentFeatures []FeatureScopeInfo) []Violation

CheckScopes compares scope definitions between base and current descriptors. Returns breaking-change violations for:

  • Scope dimension set changes
  • Scope removals (removes generated *Features type)
  • Feature scope removals (removes generated accessor method)

func (Violation) String

func (v Violation) String() string

String formats the violation for terminal output.

Jump to

Keyboard shortcuts

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