filter

package
v2.7.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeCollector

type NodeCollector interface {
	Collect(file *ast.File, fset *token.FileSet, fileAbs string)
}

NodeCollector defines the interface for types that can collect and process AST nodes from a source file.

type NodeFilter

type NodeFilter interface {
	ShouldSkip(node ast.Node, mutatorName string) bool
}

NodeFilter defines the interface for types that can determine if an AST node should be excluded from mutation.

type SkipMakeArgsFilter

type SkipMakeArgsFilter struct {
	// IgnoredNodes maps positions of numeric literals to their parent 'make' call expressions
	IgnoredNodes map[token.Pos]*ast.CallExpr
}

SkipMakeArgsFilter is a filter that tracks numeric arguments in 'make' calls for slices and maps to be ignored during mutation.

func NewSkipMakeArgsFilter

func NewSkipMakeArgsFilter() *SkipMakeArgsFilter

NewSkipMakeArgsFilter creates and returns a new initialized Processor.

func (*SkipMakeArgsFilter) Collect

func (s *SkipMakeArgsFilter) Collect(file *ast.File, _ *token.FileSet, _ string)

Collect collects numeric arguments (children) from 'make' calls (parents) for slices/maps to be ignored during mutation

func (*SkipMakeArgsFilter) ShouldSkip

func (s *SkipMakeArgsFilter) ShouldSkip(node ast.Node, _ string) bool

ShouldSkip determines whether a given AST node should be skipped during mutation.

type SourceLineRegexFilter added in v2.6.7

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

SourceLineRegexFilter skips mutations on any source line that matches one of the configured regular expressions. This lets teams suppress known-noisy patterns globally in the config file without modifying source files.

Example config usage:

ignore_source_lines:
  - "assert\\."      # skip lines that call assertion helpers
  - "//\\s*nolint"   # skip lines with nolint directives

func NewSourceLineRegexFilter added in v2.6.7

func NewSourceLineRegexFilter(patterns []string) *SourceLineRegexFilter

NewSourceLineRegexFilter compiles each pattern string and returns a filter. Patterns that fail to compile are silently skipped.

func (*SourceLineRegexFilter) Collect added in v2.6.7

func (f *SourceLineRegexFilter) Collect(file *ast.File, fset *token.FileSet, fileAbs string)

Collect reads the source file and records the positions of all AST nodes that sit on lines matching any configured pattern.

func (*SourceLineRegexFilter) ShouldSkip added in v2.6.7

func (f *SourceLineRegexFilter) ShouldSkip(node ast.Node, _ string) bool

ShouldSkip implements NodeFilter. Returns true when the node's start position falls on a line that matched a configured regex.

Jump to

Keyboard shortcuts

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