pathfinder

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedLanguages added in v0.1.4

func SupportedLanguages() []string

SupportedLanguages returns a list of all supported programming languages that PathFinder can analyze.

func Version added in v0.1.1

func Version() string

Version returns the current version of the library.

Types

type AnnotationMetrics

type AnnotationMetrics struct {
	TotalTODO        int // Count of "TODO" tags
	TotalFIXME       int // Count of "FIXME" tags
	TotalHACK        int // Count of "HACK" tags
	TotalAnnotations int // Sum of all annotation types
}

AnnotationMetrics tracks special comment tags like TODO, FIXME, and HACK.

type CodebaseMetrics

type CodebaseMetrics struct {
	TotalFiles     int // Total files scanned
	TotalDirs      int // Total directories encountered
	TotalLanguages int // Number of distinct languages detected
	TotalCode      int // Total lines of code across all languages
	TotalComments  int // Total lines of comments across all languages
	TotalBlanks    int // Total blank lines across all languages
	TotalLines     int // Grand total of all lines
}

CodebaseMetrics aggregates statistics for the entire scanned project.

type CodebaseReport

type CodebaseReport struct {
	LanguageMetrics    []LanguageMetricsReport
	FileMetrics        []FileMetricsReport
	DirMetrics         []DirMetricsReport
	CodebaseMetrics    CodebaseMetrics
	AnnotationMetrics  AnnotationMetrics
	DependencyMetrics  DependencyMetrics
	PerformanceMetrics PerformanceMetrics
}

CodebaseReport is the final output structure containing all analysis results.

func Scan added in v0.1.1

func Scan(config Config) (CodebaseReport, error)

Scan is the main entry point for the library. It takes a Config and returns a detailed CodebaseReport.

func (CodebaseReport) ScannedDirectories added in v0.1.4

func (c CodebaseReport) ScannedDirectories() []string

ScannedDirectories returns a list of all directories that were scanned in the codebase.

func (CodebaseReport) ScannedFiles added in v0.1.4

func (c CodebaseReport) ScannedFiles() []string

ScannedFiles returns a list of all files that were scanned in the codebase.

func (CodebaseReport) ScannedLanguages added in v0.1.4

func (c CodebaseReport) ScannedLanguages() []string

ScannedLanguages returns a list of all programming languages found in the scanned codebase.

type CommentType

type CommentType struct {
	SingleLine string // Prefix for single-line comments (e.g., "//" or "#")
	BlockStart string // Start marker for block comments (e.g., "/*")
	BlockEnd   string // End marker for block comments (e.g., "*/")
}

CommentType defines the comment syntax markers for a programming language.

type Config

type Config struct {
	// PathFlag is the root path to the codebase or repository to scan.
	PathFlag string

	// HiddenFlag, if true, includes hidden files and directories (starting with .) in the scan.
	HiddenFlag bool

	// BufferSizeFlag sets the buffer size (in bytes) for reading files.
	// specific values like 4KB, 8KB, 16KB is usually the best performance.
	BufferSizeFlag int

	// RecursiveFlag, if true, scans subdirectories recursively.
	RecursiveFlag bool

	// MaxDepthFlag limits the recursion depth. Set to -1 for no limit.
	// Only applies if RecursiveFlag is true.
	MaxDepthFlag int

	// DependencyFlag, if true, attempts to analyze dependency files (e.g. go.mod, package.json).
	DependencyFlag bool

	// GitFlag, if true, analyzes git information (commits, history).
	GitFlag bool

	// WorkerFlag, if set, defines the number of concurrent workers for scanning files. Default is 16
	WorkerFlag int

	// ThroughputFlag, if true, shows throughput information without the detailed report.
	ThroughputFlag bool
}

Config configures the behavior of the scanner.

type DependencyFile

type DependencyFile struct {
	Path         string   // File path to the manifest
	Type         string   // Type of dependency manager (e.g., "Go Modules", "npm")
	Dependencies []string // List of dependencies found in the file
}

DependencyFile represents a manifest file found in the project (e.g., go.mod).

type DependencyMetrics

type DependencyMetrics struct {
	TotalDependencies int              // Total count of individual dependencies found
	DependencyFiles   []DependencyFile // List of files that were parsed for dependencies
}

DependencyMetrics aggregates dependency information found during the scan.

type DirMetricsReport

type DirMetricsReport struct {
	Directory  string  // Path to the directory
	Percentage float64 // Percentage of the codebase contained in this directory
	Lines      int     // Total lines in this directory
}

DirMetricsReport contains metrics for a specific directory.

type FileMetricsReport

type FileMetricsReport struct {
	Path    string          // Relative path to the file
	Metrics LanguageMetrics // The metrics calculated for this file
}

FileMetricsReport contains metrics for a single file.

type LanguageDefinition

type LanguageDefinition struct {
	Name string      // The common name of the language (e.g., "Go", "Python")
	Type CommentType // The comment syntax definition
	Ext  []string    // List of file extensions (e.g., ".go", ".py")
}

LanguageDefinition maps a programming language to its file extensions and comment syntax.

type LanguageMetrics

type LanguageMetrics struct {
	Language string // Name of the language
	Files    int    // Number of files detected
	Code     int    // Lines of actual code
	Comments int    // Lines of comments
	Blanks   int    // Empty lines
	Lines    int    // Total lines (Code + Comments + Blanks)
}

LanguageMetrics contains the raw counts for a specific language.

type LanguageMetricsReport

type LanguageMetricsReport struct {
	Percentage float64         // Percentage of the codebase written in this language
	Metrics    LanguageMetrics // The raw metrics
}

LanguageMetricsReport wraps LanguageMetrics with a percentage relative to the whole codebase.

type PerformanceMetrics

type PerformanceMetrics struct {
	TotalWorkers      int            // Number of concurrent workers used
	WorkerStats       []*WorkerStats // Detailed stats per worker
	TotalTimeSeconds  float64        // Total time taken for the scan in seconds
	OverallThroughput float64        // Files processed per second
}

PerformanceMetrics holds the workers throughput and time taken for the scan.

type WorkerStats added in v0.3.0

type WorkerStats struct {
	Id         int     // worker ID
	Processed  int     // number of files processed
	Throughput float64 // files per second
	Duration   float64 // total time taken
	Start      time.Time
	End        time.Time
}

WorkerStats for tracking worker stats if throughput flag is enabled

Jump to

Keyboard shortcuts

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