Documentation ¶
Index ¶
- func GetDeprecatedIDToReplacementIDs[R RuleOrCategory](rulesOrCategories []R) (map[string][]string, error)
- func PrintRules(writer io.Writer, rules []Rule, options ...PrintRulesOption) (retErr error)
- type AllCategoriesOption
- type AllRulesOption
- type BreakingOption
- type Category
- type Client
- type ClientFunctionOption
- type ClientOption
- type ConfiguredRulesOption
- type LintBreakingAndConfiguredRulesOption
- type LintOption
- type PrintRulesOption
- type Rule
- type RuleOrCategory
- type RunnerProvider
- type RunnerProviderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDeprecatedIDToReplacementIDs ¶ added in v1.40.0
func GetDeprecatedIDToReplacementIDs[R RuleOrCategory](rulesOrCategories []R) (map[string][]string, error)
GetDeprecatedIDToReplacementIDs gets a map from deprecated ID to replacement IDs.
func PrintRules ¶
func PrintRules(writer io.Writer, rules []Rule, options ...PrintRulesOption) (retErr error)
PrintRules prints the rules to the Writer.
Types ¶
type AllCategoriesOption ¶ added in v1.40.0
type AllCategoriesOption interface {
// contains filtered or unexported methods
}
AllCategoriesOption is an option for AllCategories.
type AllRulesOption ¶ added in v1.40.0
type AllRulesOption interface {
// contains filtered or unexported methods
}
AllRulesOption is an option for AllRules.
type BreakingOption ¶ added in v1.40.0
type BreakingOption interface {
// contains filtered or unexported methods
}
BreakingOption is an option for Breaking.
func BreakingWithExcludeImports ¶ added in v1.40.0
func BreakingWithExcludeImports() BreakingOption
BreakingWithExcludeImports returns a new BreakingOption that says to exclude imports from breaking change detection.
The default is to check imports for breaking changes.
type Category ¶ added in v1.40.0
type Category interface { check.Category // Plugin returns the name of the plugin that created this Category. // // Names are freeform. // // Will be empty for Categorys based on builtin plugins. PluginName() string // contains filtered or unexported methods }
Category is an individual line or breaking Category.
It wraps check.Category and adds the name of the plugin that implements the Category.
type Client ¶ added in v1.40.0
type Client interface { // Lint lints the given Image with the given LintConfig. // // The Image should have source code info for this to work properly. // // Images should *not* be filtered with regards to imports before passing to this function. // // An error of type bufanalysis.FileAnnotationSet will be returned lint failure. Lint(ctx context.Context, config bufconfig.LintConfig, image bufimage.Image, options ...LintOption) error // Breaking checks the given Images for breaking changes with the given BreakingConfig. // // The Images should have source code info for this to work properly. // // Images should *not* be filtered with regards to imports before passing to this function. // To exclude imports, pass BreakingWithExcludeImports. // // An error of type bufanalysis.FileAnnotationSet will be returned lint failure. Breaking(ctx context.Context, config bufconfig.BreakingConfig, image bufimage.Image, againstImage bufimage.Image, options ...BreakingOption) error // ConfiguredRules returns all of the Configured Rules for the given RuleType. ConfiguredRules(ctx context.Context, ruleType check.RuleType, config bufconfig.CheckConfig, options ...ConfiguredRulesOption) ([]Rule, error) // AllRules returns all Rules (configured or not) for the given RuleType. AllRules(ctx context.Context, ruleType check.RuleType, fileVersion bufconfig.FileVersion, options ...AllRulesOption) ([]Rule, error) // AllCategories returns all Categories. AllCategories(ctx context.Context, fileVersion bufconfig.FileVersion, options ...AllCategoriesOption) ([]Category, error) }
Rules are returned sorted by ID, but PrintRules does our sort by category.
func NewClient ¶ added in v1.40.0
func NewClient( logger *slog.Logger, runnerProvider RunnerProvider, options ...ClientOption, ) (Client, error)
NewClient returns a new Client.
type ClientFunctionOption ¶ added in v1.40.0
type ClientFunctionOption interface { LintOption BreakingOption ConfiguredRulesOption AllRulesOption AllCategoriesOption }
ClientFunctionOption is an option that applies to any Client function.
func WithPluginConfigs ¶ added in v1.40.0
func WithPluginConfigs(pluginConfigs ...bufconfig.PluginConfig) ClientFunctionOption
WithPluginConfigs returns a new ClientFunctionOption that says to also use the given plugins.
The default is to only use the builtin Rules and Categories.
type ClientOption ¶ added in v1.40.0
type ClientOption func(*clientOptions)
ClientOption is an option for a new Client.
func ClientWithStderr ¶ added in v1.40.0
func ClientWithStderr(stderr io.Writer) ClientOption
ClientWithStderr returns a new ClientOption that specifies a stderr to proxy plugin stderrs to.
The default is the equivalent of /dev/null.
type ConfiguredRulesOption ¶ added in v1.40.0
type ConfiguredRulesOption interface {
// contains filtered or unexported methods
}
ConfiguredRulesOption is an option for ConfiguredRules.
type LintBreakingAndConfiguredRulesOption ¶ added in v1.48.0
type LintBreakingAndConfiguredRulesOption interface { LintOption BreakingOption ConfiguredRulesOption }
LintBreakingAndConfiguredRulesOption is an option for Lint, Breaking, and ConfiguredRules.
func WithRelatedCheckConfigs ¶ added in v1.48.0
func WithRelatedCheckConfigs(relatedCheckConfigs ...bufconfig.CheckConfig) LintBreakingAndConfiguredRulesOption
WithRelatedCheckConfigs returns a new LintBreakingAndConfiguredRulesOption that allows the caller to provide additional related check configs. This allows the client to check for unused plugins across related check configs and provide users with a warning if the plugin is unused in all check configs.
The default is to only check the configs provided to the client for Lint, Breaking, or ConfiguredRules.
type LintOption ¶ added in v1.40.0
type LintOption interface {
// contains filtered or unexported methods
}
LintOption is an option for Lint.
type PrintRulesOption ¶ added in v1.37.0
type PrintRulesOption func(*printRulesOptions)
PrintRulesOption is an option for PrintRules.
func PrintRulesWithDeprecated ¶ added in v1.37.0
func PrintRulesWithDeprecated() PrintRulesOption
PrintRulesWithDeprecated returns a new PrintRulesOption that results in deprecated rules being printed.
func PrintRulesWithJSON ¶ added in v1.37.0
func PrintRulesWithJSON() PrintRulesOption
PrintRulesWithJSON returns a new PrintRulesOption that says to print the rules as JSON.
The default is to print as text.
type Rule ¶
type Rule interface { check.Rule // BufcheckCategories returns the Rule's Categories. BufcheckCategories() []Category // Plugin returns the name of the plugin that created this Rule. // // Names are freeform. // // Will be empty for Rules based on builtin plugins. PluginName() string // contains filtered or unexported methods }
Rule is an individual line or breaking Rule.
It wraps check.Rule and adds the name of the plugin that implements the Rule.
type RuleOrCategory ¶ added in v1.40.0
type RuleOrCategory interface { ID() string Purpose() string Deprecated() bool ReplacementIDs() []string PluginName() string // contains filtered or unexported methods }
RuleOrCategory is a union interface with the common types in both Rule and Category.
type RunnerProvider ¶ added in v1.40.1
type RunnerProvider interface {
NewRunner(pluginConfig bufconfig.PluginConfig) (pluginrpc.Runner, error)
}
RunnerProvider provides pluginrpc.Runners for a given plugin config.
func NewLocalRunnerProvider ¶ added in v1.48.0
func NewLocalRunnerProvider( wasmRuntime wasm.Runtime, pluginKeyProvider bufplugin.PluginKeyProvider, pluginDataProvider bufplugin.PluginDataProvider, ) RunnerProvider
NewLocalRunnerProvider returns a new RunnerProvider for the wasm.Runtime and the given plugin providers.
This implementation should only be used for local applications. It is safe to use concurrently.
The RunnerProvider selects the correct Runner based on the PluginConfigType. The supported types are:
- bufconfig.PluginConfigTypeLocal
- bufconfig.PluginConfigTypeLocalWasm
- bufconfig.PluginConfigTypeRemoteWasm
If the PluginConfigType is not supported, an error is returned. To disable support for Wasm plugins, set wasmRuntime to wasm.UnimplementedRuntime. To disable support for bufconfig.PluginConfigTypeRemoteWasm Plugins, set pluginKeyProvider and pluginDataProvider to bufplugin.NopPluginKeyProvider and bufplugin.NopPluginDataProvider.
type RunnerProviderFunc ¶ added in v1.40.1
type RunnerProviderFunc func(pluginConfig bufconfig.PluginConfig) (pluginrpc.Runner, error)
RunnerProviderFunc is a function that implements RunnerProvider.
func (RunnerProviderFunc) NewRunner ¶ added in v1.40.1
func (r RunnerProviderFunc) NewRunner(pluginConfig bufconfig.PluginConfig) (pluginrpc.Runner, error)
NewRunner implements RunnerProvider.
RunnerProvider selects the correct Runner based on the type of pluginConfig.