analyzer

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Analyze

func Analyze(ctx context.Context, rootPath string, filter *Filter) (*model.Stats, error)

Analyze is the main entry point that decides between git and non-git analysis

func AnalyzeFiles

func AnalyzeFiles(ctx context.Context, rootPath string, filter *Filter) (*model.Stats, error)

AnalyzeFiles analyzes files in a non-git directory

func AnalyzeGit

func AnalyzeGit(ctx context.Context, rootPath string, filter *Filter) (*model.Stats, error)

AnalyzeGit analyzes a git repository for changes

func CountLines

func CountLines(filePath string) (int, error)

CountLines counts the number of lines in a file using chunked reading Returns 0 for binary files (detected by null bytes in first chunk)

func GetRepoRoot

func GetRepoRoot(path string) (string, error)

GetRepoRoot returns the root path of the git repository

func IsGitRepo

func IsGitRepo(path string) bool

IsGitRepo checks if the given path is a git repository

func ShouldWarnLargeDirectory added in v1.0.1

func ShouldWarnLargeDirectory(path string) (bool, string)

ShouldWarnLargeDirectory checks if we should warn the user about analyzing a large directory

func ValidatePath added in v1.0.1

func ValidatePath(path string) error

ValidatePath checks if the given path is safe to analyze Returns an error if the path is considered dangerous

Types

type Analyzer

type Analyzer interface {
	Analyze(ctx context.Context, rootPath string, filter *Filter) (*model.Stats, error)
}

Analyzer defines the interface for analyzing file statistics

func GetAnalyzer

func GetAnalyzer(rootPath string) Analyzer

GetAnalyzer returns the appropriate analyzer based on whether the path is a Git repository

type FileAnalyzer

type FileAnalyzer struct{}

FileAnalyzer implements Analyzer for non-Git directories

func NewFileAnalyzer

func NewFileAnalyzer() *FileAnalyzer

func (*FileAnalyzer) Analyze

func (f *FileAnalyzer) Analyze(ctx context.Context, rootPath string, filter *Filter) (*model.Stats, error)

type Filter

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

Filter handles file exclusion logic

func NewFilter

func NewFilter(allowedExts []string, customExcludes []string, respectGitignore bool, excludeTests bool) *Filter

NewFilter creates a new filter with default or custom settings

func (*Filter) LoadGitignore

func (f *Filter) LoadGitignore(repoRoot string) error

LoadGitignore parses .gitignore file and loads patterns

func (*Filter) ShouldInclude

func (f *Filter) ShouldInclude(path string) bool

ShouldInclude checks if a file should be included based on all filters

type GitAnalyzer

type GitAnalyzer struct{}

GitAnalyzer implements Analyzer for Git repositories

func NewGitAnalyzer

func NewGitAnalyzer() *GitAnalyzer

NewGitAnalyzer creates a new GitAnalyzer

func (*GitAnalyzer) Analyze

func (g *GitAnalyzer) Analyze(ctx context.Context, rootPath string, filter *Filter) (*model.Stats, error)

Jump to

Keyboard shortcuts

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