linter

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

Linter stores data to use for linting.

func NewEmptyLinter

func NewEmptyLinter() Linter

NewEmptyLinter creates a linter with no rule bundles.

func NewLinter

func NewLinter() Linter

NewLinter creates a new Regal linter.

func (Linter) DetermineEnabledRules

func (l Linter) DetermineEnabledRules(ctx context.Context) ([]string, []string, error)

DetermineEnabledRules returns the list of rules that are enabled based on the supplied configuration. This makes use of the linter rule settings to produce a single list of the rules that are to be run on this linter instance.

func (Linter) GetConfig

func (l Linter) GetConfig() (*config.Config, error)

GetConfig returns the final configuration for the linter, i.e. Regal's default configuration plus any user-provided configuration merged on top of it.

func (Linter) Lint

func (l Linter) Lint(ctx context.Context) (report.Report, error)

Lint runs the linter on provided policies.

func (Linter) MustPrepare

func (l Linter) MustPrepare(ctx context.Context) Linter

MustPrepare prepares the linter and panics on errors. Mostly used for tests. Experimental: see description of Prepare.

func (Linter) Prepare

func (l Linter) Prepare(ctx context.Context) (Linter, error)

Prepare stores linter preparation state, like the determined configuration, and the query perpared for linting. Experimental: while used internally, the details of what is prepared here are very likely to change in the future, and this method should not yet be relied on by external clients.

func (Linter) WithAddedBundle

func (l Linter) WithAddedBundle(b *bundle.Bundle) Linter

WithAddedBundle adds a bundle of rules and data to include in evaluation.

func (Linter) WithAggregates

func (l Linter) WithAggregates(aggregates map[string][]report.Aggregate) Linter

WithAggregates supplies aggregate data to a linter instance. Likely generated in a previous run, and used to provide a global context to a subsequent run of a single file lint.

func (Linter) WithBaseCache

func (l Linter) WithBaseCache(baseCache topdown.BaseCache) Linter

WithBaseCache sets the base cache (cache for "JSON" documents) to use for evaluation. This feature is **experimental** and should not be relied on by external clients for the time being.

func (Linter) WithCollectQuery

func (l Linter) WithCollectQuery(enabled bool) Linter

WithCollectQuery forcibly enables the collect query even when there is only one file to lint.

func (Linter) WithCustomRules

func (l Linter) WithCustomRules(paths []string) Linter

WithCustomRules adds custom rules for evaluation, from the Rego (and data) files provided at paths.

func (Linter) WithCustomRulesFromFS

func (l Linter) WithCustomRulesFromFS(f fs.FS, rootPath string) Linter

WithCustomRulesFromFS adds custom rules for evaluation from a filesystem implementing the fs.FS interface. A root path within the filesystem must also be specified. Note, _test.rego files will be ignored.

func (Linter) WithDebugMode

func (l Linter) WithDebugMode(debugMode bool) Linter

WithDebugMode enables debug mode.

func (Linter) WithDisableAll

func (l Linter) WithDisableAll(disableAll bool) Linter

WithDisableAll disables all rules when set to true. This overrides configuration provided in file.

func (Linter) WithDisabledCategories

func (l Linter) WithDisabledCategories(disableCategory ...string) Linter

WithDisabledCategories disables provided categories of rules. This overrides configuration provided in file.

func (Linter) WithDisabledRules

func (l Linter) WithDisabledRules(disable ...string) Linter

WithDisabledRules disables provided rules. This overrides configuration provided in file.

func (Linter) WithEnableAll

func (l Linter) WithEnableAll(enableAll bool) Linter

WithEnableAll enables all rules when set to true. This overrides configuration provided in file.

func (Linter) WithEnabledCategories

func (l Linter) WithEnabledCategories(enableCategory ...string) Linter

WithEnabledCategories enables provided categories of rules. This overrides configuration provided in file.

func (Linter) WithEnabledRules

func (l Linter) WithEnabledRules(enable ...string) Linter

WithEnabledRules enables provided rules. This overrides configuration provided in file.

func (Linter) WithExportAggregates

func (l Linter) WithExportAggregates(enabled bool) Linter

WithExportAggregates enables the setting of intermediate aggregate data on the final report. This is useful when you want to collect and aggregate state from multiple different linting runs.

func (Linter) WithIgnore

func (l Linter) WithIgnore(ignore []string) Linter

WithIgnore excludes files matching patterns. This overrides configuration provided in file.

func (Linter) WithInputModules

func (l Linter) WithInputModules(input *rules.Input) Linter

WithInputModules sets the input modules to lint. This is used for programmatic access, where you don't necessarily want to lint *files*.

func (Linter) WithInputPaths

func (l Linter) WithInputPaths(paths []string) Linter

WithInputPaths sets the inputPaths to lint. Note that these will be filtered according to the ignore options.

func (Linter) WithInstrumentation

func (l Linter) WithInstrumentation(enabled bool) Linter

WithInstrumentation enables instrumentation metrics.

func (Linter) WithMetrics

func (l Linter) WithMetrics(m metrics.Metrics) Linter

WithMetrics enables metrics collection.

func (Linter) WithPathPrefix

func (l Linter) WithPathPrefix(pathPrefix string) Linter

WithPathPrefix sets the root path prefix for the linter. A root directory prefix can be used to resolve relative paths referenced in the linter configuration with absolute file paths or URIs.

func (Linter) WithPrintHook

func (l Linter) WithPrintHook(printHook print.Hook) Linter

func (Linter) WithProfiling

func (l Linter) WithProfiling(enabled bool) Linter

WithProfiling enables profiling metrics.

func (Linter) WithUserConfig

func (l Linter) WithUserConfig(cfg config.Config) Linter

WithUserConfig provides config overrides set by the user.