pathfilter

package
v0.0.0-...-ffc4fba Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pathfilter excludes vendor, third-party, and generated files from analysis. It uses enry as the foundation for vendor detection and adds supplementary generated-file name patterns that enry does not cover.

A Filter is immutable after construction and safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

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

Filter determines whether a file should be excluded from analysis. It combines enry vendor detection with generated-file name patterns.

func New

func New(opts ...Option) *Filter

New creates a Filter. With no options, it uses DefaultRules.

func (*Filter) IsExcluded

func (f *Filter) IsExcluded(filePath string) bool

IsExcluded reports whether the given path should be excluded from analysis. This performs path-only checks (no file content needed).

func (*Filter) IsExcludedWithContent

func (f *Filter) IsExcludedWithContent(filePath string, content []byte) bool

IsExcludedWithContent performs path-only checks first, then inspects the first line of content for generated-file markers (e.g., "DO NOT EDIT").

func (*Filter) IsGeneratedContent

func (f *Filter) IsGeneratedContent(content []byte) bool

IsGeneratedContent checks file content for generated-file header markers.

func (*Filter) IsGeneratedPath

func (f *Filter) IsGeneratedPath(filePath string) bool

IsGeneratedPath checks suffix and filename-prefix rules only (no enry.IsVendor). This allows callers to distinguish vendor files from generated files.

type Option

type Option func(*Filter)

Option configures a Filter.

func DefaultRules

func DefaultRules() Option

DefaultRules returns an Option that populates the filter with built-in generated-file patterns. Vendor detection is always handled by enry.

Jump to

Keyboard shortcuts

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