fixer

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAllFixesColumns

func ApplyAllFixesColumns(columns *scanner.FindingColumns, suffix string) (totalFixes int, filesModified int, errors []error)

ApplyAllFixesColumns applies text fixes from columnar findings across all files. It reconstructs only rows that carry text fixes, preserving the existing file-level fixer behavior without materializing the entire finding set.

func ApplyBinaryFixesBatchColumns

func ApplyBinaryFixesBatchColumns(columns *scanner.FindingColumns, dryRun bool, searchDirs ...[]string) (applied int, errors []error)

ApplyBinaryFixesBatchColumns applies binary fixes from columnar findings in the same safe order as ApplyBinaryFixesBatch, working directly with columnar data.

func SetLogger

func SetLogger(l logger.Logger)

SetLogger replaces the package-level Logger. Intended for tests.

func ValidateBinaryFix

func ValidateBinaryFix(fix *scanner.BinaryFix, searchDirs []string) ([]android.FileReference, error)

ValidateBinaryFix checks whether a BinaryFix can be safely applied. For WebP conversions it performs three checks:

  1. Animated asset detection: animated GIFs and APNGs cannot be safely converted to static WebP. If the source is animated, an error is returned.

  2. MinSdk compatibility: WebP lossy requires API 14, WebP lossless/transparency requires API 18. If BinaryFix.MinSdk is set and below the threshold, an error is returned.

  3. Direct file reference scan: scans Kotlin, Java, and XML files for literal occurrences of the source file name (e.g. "icon.png"). Android resource references like "@drawable/icon" are safe because they resolve by name without extension, but direct file-name strings would break after conversion.

Returns (nil, error) for safety failures (animated, minSdk). Returns (refs, nil) when direct file references are found (caller decides). Returns (nil, nil) when the fix is safe.

func ValidateFixResult

func ValidateFixResult(path string, original, fixed []byte) error

ValidateFixResult checks whether the given content (for a .kt file) still parses without additional errors compared to the original. This is opt-in validation.

Types

type DroppedFix

type DroppedFix struct {
	Rule string
	File string
	Line int
}

DroppedFix records a fix that was dropped due to overlap conflict.

type FixResult

type FixResult struct {
	Applied      int
	DroppedFixes []DroppedFix
}

FixResult holds the result of applying fixes to a file.

Jump to

Keyboard shortcuts

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