helpers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoFilesFound      = errors.New("no supported source files found in path")
	ErrInvalidFormat     = errors.New("invalid output format: must be text, json, sarif, or md")
	ErrThresholdExceeded = errors.New("duplication percentage exceeds threshold")
	ErrInvalidMinLines   = errors.New("min-lines must be greater than 0")
	ErrInvalidMinTokens  = errors.New("min-tokens must be greater than 0")
	ErrPathNotFound      = errors.New("path does not exist")
	// ErrClonesFound is returned by the scan action when duplicates are detected.
	// main() maps this to exit code 1 (distinct from exit code 2 for tool errors).
	ErrClonesFound = errors.New("duplicate code detected")
	// ErrTooManyFiles is returned when the file collector hits the --max-files
	// safety cap. This is the fail-fast guard for runaway scans on huge trees.
	ErrTooManyFiles = errors.New("too many files to scan: raise --max-files or narrow --include")
	// ErrTooManyPairs is returned when the fuzzy detector would build more
	// candidate pairs than --max-pairs allows. The fix is one of:
	// raise --max-pairs, lower --max-bucket, or disable fuzzy with --similarity 1.0.
	ErrTooManyPairs = errors.New("fuzzy detector exceeded --max-pairs cap: lower --max-bucket, raise --max-pairs, or disable fuzzy with --similarity 1.0")
)
View Source
var ErrMemoryBudget = errors.New("scan does not fit in the memory budget")

ErrMemoryBudget is returned when a scan cannot fit in its memory budget.

Log is the global logger instance.

Functions

func ParseByteSize added in v0.2.0

func ParseByteSize(s string) (int64, error)

ParseByteSize parses a size such as "512M", "2G", "1.5GiB" or a plain byte count. Units are binary (1K = 1024 bytes) and case-insensitive.

func SetupLogger

func SetupLogger(level string)

SetupLogger initializes the global logger with the given level.

func SystemMemoryBudget added in v0.2.0

func SystemMemoryBudget() int64

SystemMemoryBudget returns the default memory budget for a scan: half of the memory this process is allowed to use, so a scan cannot starve the machine or its container. It returns 0 (no budget) where that cannot be determined — the limits are read from Linux's /proc and cgroup files.

Types

This section is empty.

Jump to

Keyboard shortcuts

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