Documentation
¶
Overview ¶
Package tools provides quality tool implementations for multiple programming languages.
Index ¶
- func FilterFilesByExtensions(files, extensions []string) []string
- type BaseTool
- func (t *BaseTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
- func (t *BaseTool) Execute(ctx context.Context, files []string, options ExecuteOptions) (*Result, error)
- func (t *BaseTool) ExecuteCommand(ctx context.Context, cmd *exec.Cmd, files []string) (*Result, error)
- func (t *BaseTool) FindConfigFiles(projectRoot string) []string
- func (t *BaseTool) GetVersion() (string, error)
- func (t *BaseTool) Install() error
- func (t *BaseTool) IsAvailable() bool
- func (t *BaseTool) Language() string
- func (t *BaseTool) Name() string
- func (t *BaseTool) ParseOutput(output string) []Issue
- func (t *BaseTool) SetConfigPatterns(patterns []string)
- func (t *BaseTool) SetInstallCommand(cmd []string)
- func (t *BaseTool) Type() ToolType
- func (t *BaseTool) Upgrade() error
- type BlackTool
- type CargoFmtTool
- type ClippyTool
- type ConfigDetector
- type DefaultRegistry
- func (r *DefaultRegistry) FindTool(name string) QualityTool
- func (r *DefaultRegistry) GetTools() []QualityTool
- func (r *DefaultRegistry) GetToolsByLanguage(language string) []QualityTool
- func (r *DefaultRegistry) GetToolsByType(toolType ToolType) []QualityTool
- func (r *DefaultRegistry) Register(tool QualityTool)
- type ESLintTool
- type ExecuteOptions
- type ExecutionPlan
- type Executor
- type GofumptTool
- type GoimportsTool
- type GolangciLintTool
- type Issue
- type LanguageDetector
- type PrettierTool
- type PylintTool
- type QualityTool
- type Result
- type RuffTool
- type RustfmtTool
- type TSCTool
- type Task
- type ToolRegistry
- type ToolType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterFilesByExtensions ¶
FilterFilesByExtensions filters files by supported extensions.
Types ¶
type BaseTool ¶
type BaseTool struct {
// contains filtered or unexported fields
}
BaseTool provides common functionality for quality tools.
func NewBaseTool ¶
NewBaseTool creates a new base tool.
func (*BaseTool) BuildCommand ¶
func (t *BaseTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the command to execute (to be implemented by specific tools).
func (*BaseTool) Execute ¶
func (t *BaseTool) Execute(ctx context.Context, files []string, options ExecuteOptions) (*Result, error)
Execute runs the tool on the specified files.
func (*BaseTool) ExecuteCommand ¶
func (t *BaseTool) ExecuteCommand(ctx context.Context, cmd *exec.Cmd, files []string) (*Result, error)
ExecuteCommand runs a command and returns the result.
func (*BaseTool) FindConfigFiles ¶
FindConfigFiles returns configuration files the tool would use.
func (*BaseTool) GetVersion ¶
GetVersion returns the version of the installed tool.
func (*BaseTool) IsAvailable ¶
IsAvailable checks if the tool is installed and available.
func (*BaseTool) ParseOutput ¶
ParseOutput parses tool output into issues (to be implemented by specific tools).
func (*BaseTool) SetConfigPatterns ¶
SetConfigPatterns sets the configuration file patterns to search for.
func (*BaseTool) SetInstallCommand ¶
SetInstallCommand sets the command to install this tool.
type BlackTool ¶
type BlackTool struct {
*BaseTool
}
BlackTool implements Python formatting using black.
func (*BlackTool) BuildCommand ¶
func (t *BlackTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the black command.
type CargoFmtTool ¶
type CargoFmtTool struct {
*BaseTool
}
CargoFmtTool implements Rust formatting using cargo fmt.
func NewCargoFmtTool ¶
func NewCargoFmtTool() *CargoFmtTool
NewCargoFmtTool creates a new cargo fmt tool.
func (*CargoFmtTool) BuildCommand ¶
func (t *CargoFmtTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the cargo fmt command.
type ClippyTool ¶
type ClippyTool struct {
*BaseTool
}
ClippyTool implements Rust linting using clippy.
func (*ClippyTool) BuildCommand ¶
func (t *ClippyTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the clippy command.
func (*ClippyTool) ParseOutput ¶
func (t *ClippyTool) ParseOutput(output string) []Issue
ParseOutput parses clippy JSON output.
type ConfigDetector ¶
type ConfigDetector interface {
// FindConfigs searches for tool configuration files
FindConfigs(projectRoot string, tools []QualityTool) map[string]string
// ValidateConfig checks if a configuration file is valid
ValidateConfig(toolName, configPath string) error
}
ConfigDetector finds configuration files for quality tools.
type DefaultRegistry ¶
type DefaultRegistry struct {
// contains filtered or unexported fields
}
DefaultRegistry is the default registry implementation.
func (*DefaultRegistry) FindTool ¶
func (r *DefaultRegistry) FindTool(name string) QualityTool
FindTool finds a tool by name.
func (*DefaultRegistry) GetTools ¶
func (r *DefaultRegistry) GetTools() []QualityTool
GetTools returns all registered tools.
func (*DefaultRegistry) GetToolsByLanguage ¶
func (r *DefaultRegistry) GetToolsByLanguage(language string) []QualityTool
GetToolsByLanguage returns tools for a specific language.
func (*DefaultRegistry) GetToolsByType ¶
func (r *DefaultRegistry) GetToolsByType(toolType ToolType) []QualityTool
GetToolsByType returns tools of a specific type.
func (*DefaultRegistry) Register ¶
func (r *DefaultRegistry) Register(tool QualityTool)
Register adds a tool to the registry.
type ESLintTool ¶
type ESLintTool struct {
*BaseTool
}
ESLintTool implements JavaScript/TypeScript linting using eslint.
func (*ESLintTool) BuildCommand ¶
func (t *ESLintTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the eslint command.
func (*ESLintTool) ParseOutput ¶
func (t *ESLintTool) ParseOutput(output string) []Issue
ParseOutput parses eslint JSON output.
type ExecuteOptions ¶
type ExecuteOptions struct {
// ProjectRoot is the root directory of the project
ProjectRoot string
// ConfigFile is the path to the tool's configuration file
ConfigFile string
// Fix indicates whether to auto-fix issues (if supported)
Fix bool
// FormatOnly runs only formatting (for tools that support both)
FormatOnly bool
// LintOnly runs only linting (for tools that support both)
LintOnly bool
// ExtraArgs are additional arguments to pass to the tool
ExtraArgs []string
// Env contains environment variables for the tool
Env map[string]string
}
ExecuteOptions contains options for tool execution.
type ExecutionPlan ¶
type ExecutionPlan struct {
// Tasks are the individual tool execution tasks
Tasks []Task
// TotalFiles is the total number of files to be processed
TotalFiles int
// EstimatedDuration is the estimated time to complete all tasks
EstimatedDuration string
}
ExecutionPlan represents a plan for executing quality tools.
type Executor ¶
type Executor interface {
// Execute runs the execution plan
Execute(ctx context.Context, plan *ExecutionPlan) ([]*Result, error)
// ExecuteParallel runs the plan with parallel execution
ExecuteParallel(ctx context.Context, plan *ExecutionPlan, workers int) ([]*Result, error)
}
Executor runs quality tools according to an execution plan.
type GofumptTool ¶
type GofumptTool struct {
*BaseTool
}
GofumptTool implements Go formatting using gofumpt.
func (*GofumptTool) BuildCommand ¶
func (t *GofumptTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the gofumpt command.
type GoimportsTool ¶
type GoimportsTool struct {
*BaseTool
}
GoimportsTool implements Go import formatting using goimports.
func NewGoimportsTool ¶
func NewGoimportsTool() *GoimportsTool
NewGoimportsTool creates a new goimports tool.
func (*GoimportsTool) BuildCommand ¶
func (t *GoimportsTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the goimports command.
type GolangciLintTool ¶
type GolangciLintTool struct {
*BaseTool
}
GolangciLintTool implements Go linting using golangci-lint.
func NewGolangciLintTool ¶
func NewGolangciLintTool() *GolangciLintTool
NewGolangciLintTool creates a new golangci-lint tool.
func (*GolangciLintTool) BuildCommand ¶
func (t *GolangciLintTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the golangci-lint command.
func (*GolangciLintTool) ParseOutput ¶
func (t *GolangciLintTool) ParseOutput(output string) []Issue
ParseOutput parses golangci-lint JSON output.
type Issue ¶
type Issue struct {
// File is the path to the file containing the issue
File string
// Line is the line number (1-based)
Line int
// Column is the column number (1-based)
Column int
// Severity is the issue severity (error, warning, info)
Severity string
// Rule is the rule that was violated
Rule string
// Message is the issue description
Message string
// Suggestion is an optional fix suggestion
Suggestion string
}
Issue represents a code quality issue found by a tool.
type LanguageDetector ¶
type LanguageDetector interface {
// DetectLanguages scans a directory and returns detected languages
DetectLanguages(projectRoot string) ([]string, error)
// GetFilesByLanguage returns files grouped by language
GetFilesByLanguage(projectRoot string, languages []string) (map[string][]string, error)
}
LanguageDetector detects programming languages in a project.
type PrettierTool ¶
type PrettierTool struct {
*BaseTool
}
PrettierTool implements JavaScript/TypeScript formatting using prettier.
func NewPrettierTool ¶
func NewPrettierTool() *PrettierTool
NewPrettierTool creates a new prettier tool.
func (*PrettierTool) BuildCommand ¶
func (t *PrettierTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the prettier command.
type PylintTool ¶
type PylintTool struct {
*BaseTool
}
PylintTool implements Python linting using pylint.
func (*PylintTool) BuildCommand ¶
func (t *PylintTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the pylint command.
func (*PylintTool) ParseOutput ¶
func (t *PylintTool) ParseOutput(output string) []Issue
ParseOutput parses pylint JSON output.
type QualityTool ¶
type QualityTool interface {
// Name returns the tool name (e.g., "gofumpt", "eslint")
Name() string
// Language returns the programming language (e.g., "Go", "Python")
Language() string
// Type returns the tool type (FORMAT, LINT, or BOTH)
Type() ToolType
// IsAvailable checks if the tool is installed and available
IsAvailable() bool
// Install attempts to install the tool automatically
Install() error
// GetVersion returns the version of the installed tool
GetVersion() (string, error)
// Upgrade attempts to upgrade the tool to the latest version
Upgrade() error
// FindConfigFiles returns configuration files the tool would use
FindConfigFiles(projectRoot string) []string
// Execute runs the tool on the specified files
Execute(ctx context.Context, files []string, options ExecuteOptions) (*Result, error)
}
QualityTool represents a code quality tool (formatter or linter).
type Result ¶
type Result struct {
// Tool is the name of the tool that was executed
Tool string
// Language is the programming language
Language string
// Success indicates whether the tool executed successfully
Success bool
// Error contains any execution error
Error error
// FilesProcessed is the number of files processed
FilesProcessed int
// Duration is how long the tool took to run
Duration string
// Issues contains any issues found by the tool
Issues []Issue
// Output contains the raw output from the tool
Output string
}
Result contains the results of tool execution.
type RuffTool ¶
type RuffTool struct {
*BaseTool
}
RuffTool implements Python linting and formatting using ruff.
func (*RuffTool) BuildCommand ¶
func (t *RuffTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the ruff command.
func (*RuffTool) Execute ¶
func (t *RuffTool) Execute(ctx context.Context, files []string, options ExecuteOptions) (*Result, error)
Execute overrides the base Execute to handle both format and lint modes.
func (*RuffTool) ParseOutput ¶
ParseOutput parses ruff JSON output.
type RustfmtTool ¶
type RustfmtTool struct {
*BaseTool
}
RustfmtTool implements Rust formatting using rustfmt.
func (*RustfmtTool) BuildCommand ¶
func (t *RustfmtTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the rustfmt command.
type TSCTool ¶
type TSCTool struct {
*BaseTool
}
TSCTool implements TypeScript type checking using tsc.
func (*TSCTool) BuildCommand ¶
func (t *TSCTool) BuildCommand(files []string, options ExecuteOptions) *exec.Cmd
BuildCommand builds the tsc command.
func (*TSCTool) ParseOutput ¶
ParseOutput parses tsc output.
type Task ¶
type Task struct {
// Tool is the quality tool to execute
Tool QualityTool
// Files are the files to process
Files []string
// Options are the execution options
Options ExecuteOptions
// Priority affects execution order (higher = earlier)
Priority int
}
Task represents a single tool execution task.
type ToolRegistry ¶
type ToolRegistry interface {
// Register adds a tool to the registry
Register(tool QualityTool)
// GetTools returns all registered tools
GetTools() []QualityTool
// GetToolsByLanguage returns tools for a specific language
GetToolsByLanguage(language string) []QualityTool
// GetToolsByType returns tools of a specific type
GetToolsByType(toolType ToolType) []QualityTool
// FindTool finds a tool by name
FindTool(name string) QualityTool
}
ToolRegistry manages available quality tools.