config

package
v0.0.0-...-9fcf0b5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0, MIT Imports: 3 Imported by: 2

Documentation

Overview

Package config defines a filter configuration for nogo findings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzerConfig

type AnalyzerConfig map[GroupName]*ItemConfig

AnalyzerConfig is the configuration for a single analyzers.

This map is keyed by individual Group names, to allow for different configurations depending on what Group the file belongs to.

func (AnalyzerConfig) RegexpCount

func (a AnalyzerConfig) RegexpCount() int64

RegexpCount is used by Config.Size.

type Config

type Config struct {
	// Prefixes defines a set of regular expressions that
	// are standard "prefixes", so that files can be grouped
	// and specific rules applied to individual groups.
	Groups []Group `yaml:"groups"`

	// Global is the global analyzer config.
	Global AnalyzerConfig `yaml:"global"`

	// Analyzers are individual analyzer configurations. The
	// key for each analyzer is the name of the analyzer. The
	// value is either a boolean (enable/disable), or a map to
	// the groups above.
	Analyzers map[string]AnalyzerConfig `yaml:"analyzers"`
}

Config is a nogo configuration.

func (*Config) Compile

func (c *Config) Compile() error

Compile compiles a configuration to make it useable.

func (*Config) Merge

func (c *Config) Merge(other *Config)

Merge merges two configurations.

func (*Config) ShouldReport

func (c *Config) ShouldReport(finding check.Finding) bool

ShouldReport returns true iff the finding should match the Config.

type Group

type Group struct {
	// Name is the short name for the group.
	Name GroupName `yaml:"name"`

	// Regex matches all full paths in the group.
	Regex string `yaml:"regex"`

	// Default determines the default group behavior.
	//
	// If Default is true, all Analyzers are enabled for this
	// group. Otherwise, Analyzers must be individually enabled
	// by specifying a (possible empty) ItemConfig for the group
	// in the AnalyzerConfig.
	Default bool `yaml:"default"`
	// contains filtered or unexported fields
}

Group represents a named collection of files.

type GroupName

type GroupName string

GroupName is a named group.

type ItemConfig

type ItemConfig struct {
	// Exclude are analyzer exclusions.
	//
	// Exclude is a list of regular expressions. If the corresponding
	// Analyzer emits a Finding for which Finding.Position.String()
	// matches a regular expression in Exclude, the finding will not
	// be reported.
	Exclude []string `yaml:"exclude,omitempty"`

	// Suppress are analyzer suppressions.
	//
	// Suppress is a list of regular expressions. If the corresponding
	// Analyzer emits a Finding for which Finding.Message matches a regular
	// expression in Suppress, the finding will not be reported.
	Suppress []string `yaml:"suppress,omitempty"`
	// contains filtered or unexported fields
}

ItemConfig is an (Analyzer,Group) configuration.

func (*ItemConfig) RegexpCount

func (i *ItemConfig) RegexpCount() int64

RegexpCount is used by AnalyzerConfig.RegexpCount.

Jump to

Keyboard shortcuts

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