config

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFlagSet

func CreateFlagSet() *flag.FlagSet

CreateFlagSet creates and returns a flagset with gogreement-specific flags. This allows the flags to be registered in the analyzer and appear in help. IMPORTANT: Flag names are automatically prefixed with "config" by multichecker framework when used in the config analyzer. Do not modify flag names as it affects CLI.

Types

type Config

type Config struct {
	// ScanTests determines whether test files should be analyzed
	// By default, test files (*_test.go) are excluded from analysis
	// Environment variable: GOGREEMENT_SCAN_TESTS=true|false
	// Command line flag: --scan-tests=true|false
	ScanTests bool

	// ExcludePaths is a list of path patterns to exclude from analysis
	// Paths are matched as substrings (e.g. "testdata" will exclude any path containing "testdata")
	// Environment variable: GOGREEMENT_EXCLUDE_PATHS=path1,path2,path3
	// Command line flag: --exclude-paths=path1,path2,path3
	// Default: ["testdata"]
	ExcludePaths []string

	// ExcludeChecks is a list of check codes to exclude from analysis
	// Can be individual codes (IMM01) or categories (IMM) or ALL
	// Environment variable: GOGREEMENT_EXCLUDE_CHECKS=IMM01,CTOR,TONL
	// Command line flag: --exclude-checks=IMM01,CTOR,TONL
	// Default: [] (no exclusions)
	ExcludeChecks []string
}

Config holds the configuration for gogreement analyzers @immutable @constructor New

func Default

func Default() *Config

Default returns the default configuration

func Empty

func Empty() *Config

func FromEnv

func FromEnv() *Config

FromEnv creates a new Config from environment variables.

func New

func New(scanTests bool, excludePaths []string, excludeChecks []string) *Config

New creates a new Config with specified settings

func ParseFlagsFromFlagSet

func ParseFlagsFromFlagSet(fs *flag.FlagSet) *Config

ParseFlagsFromFlagSet parses configuration from a FlagSet and environment variables. Command line flags from the FlagSet take priority over environment variables. If GOGREEMENT_ENV_ONLY is set, will use only environment variables (for testing).

func (*Config) FilterFiles

func (c *Config) FilterFiles(pass *analysis.Pass) iter.Seq[*ast.File]

FilterFiles returns only the files that should be analyzed based on configuration

func (*Config) ShouldSkipFile

func (c *Config) ShouldSkipFile(pass *analysis.Pass, file *ast.File) bool

ShouldSkipFile returns true if the file should be skipped based on configuration

func (*Config) WithExcludeChecks

func (c *Config) WithExcludeChecks(excludeChecks []string) *Config

WithExcludeChecks returns a new Config with ExcludeChecks set to the specified value

func (*Config) WithExcludePaths

func (c *Config) WithExcludePaths(excludePaths []string) *Config

WithExcludePaths returns a new Config with ExcludePaths set to the specified value

func (*Config) WithScanTests

func (c *Config) WithScanTests(scanTests bool) *Config

WithScanTests returns a new Config with ScanTests set to the specified value

Jump to

Keyboard shortcuts

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