rules

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input struct {
	// FileNames is used to maintain consistent order between runs.
	FileNames []string
	// FileContent carries the string contents of each file
	FileContent map[string]string
	// Modules is the set of modules to lint.
	Modules map[string]*ast.Module
}

Input represents the input for a linter evaluation.

func InputFromPaths

func InputFromPaths(paths []string) (Input, error)

InputFromPaths creates a new Input from a set of file or directory paths. Note that this function assumes that the paths point to valid Rego files. Use config.FilterIgnoredPaths to filter out unwanted content *before* calling this function.

func InputFromText added in v0.9.0

func InputFromText(fileName, text string) (Input, error)

InputFromText creates a new Input from raw Rego text.

func NewInput

func NewInput(fileContent map[string]string, modules map[string]*ast.Module) Input

NewInput creates a new Input from a set of modules.

type OpaFmtRule

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

func NewOpaFmtRule

func NewOpaFmtRule(conf config.Config) *OpaFmtRule

func (*OpaFmtRule) Category

func (*OpaFmtRule) Category() string

func (*OpaFmtRule) Config

func (f *OpaFmtRule) Config() config.Rule

func (*OpaFmtRule) Description

func (*OpaFmtRule) Description() string

func (*OpaFmtRule) Documentation

func (*OpaFmtRule) Documentation() string

func (*OpaFmtRule) Name

func (*OpaFmtRule) Name() string

func (*OpaFmtRule) Run

func (f *OpaFmtRule) Run(ctx context.Context, input Input) (*report.Report, error)

type Rule

type Rule interface {
	// Run runs the rule on the provided input.
	Run(context.Context, Input) (*report.Report, error)
	// Name returns the name of the rule.
	Name() string
	// Category returns the category of the rule.
	Category() string
	// Description returns the description of the rule.
	Description() string
	// Documentation returns the documentation URL for the rule.
	Documentation() string
	// Config returns the provided configuration for the rule
	Config() config.Rule
}

Rule represents a linter rule.

func AllGoRules

func AllGoRules(conf config.Config) []Rule

Jump to

Keyboard shortcuts

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