validate

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package validate provides comprehensive validation utilities for checking resolved files and running project-specific validation tools

Index

Constants

View Source
const (
	SeverityError   = "error"
	SeverityWarning = "warning"
	SeverityInfo    = "info"

	ScriptBuild     = "build"
	ScriptTest      = "test"
	ScriptLint      = "lint"
	ScriptCheck     = "check"
	ScriptValidate  = "validate"
	ScriptFormat    = "format"
	ScriptTypeCheck = "type-check"
)

Constants for commonly used strings

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandResult

type CommandResult struct {
	Command    ValidationCommand `json:"command"`
	Success    bool              `json:"success"`
	ExitCode   int               `json:"exit_code"`
	Stdout     string            `json:"stdout"`
	Stderr     string            `json:"stderr"`
	Duration   time.Duration     `json:"duration"`
	Error      string            `json:"error,omitempty"`
	Skipped    bool              `json:"skipped"`
	SkipReason string            `json:"skip_reason,omitempty"`
}

CommandResult represents the result of executing a validation command

func ExecuteValidationCommands

func ExecuteValidationCommands(commands []ValidationCommand, timeoutSeconds int) []CommandResult

ExecuteValidationCommands runs validation commands with timeout and error handling

type ProjectInfo

type ProjectInfo struct {
	Type          ProjectType `json:"type"`
	RootPath      string      `json:"root_path"`
	ConfigFiles   []string    `json:"config_files"`
	DetectedTools []string    `json:"detected_tools"`
}

ProjectInfo contains information about the detected project

func DiscoverProject

func DiscoverProject(rootPath string) (*ProjectInfo, error)

DiscoverProject analyzes the given directory to determine project type and available tools

type ProjectType

type ProjectType string

ProjectType represents the type of project detected

const (
	ProjectTypeGo         ProjectType = "go"
	ProjectTypeJavaScript ProjectType = "javascript"
	ProjectTypeTypeScript ProjectType = "typescript"
	ProjectTypePython     ProjectType = "python"
	ProjectTypeRust       ProjectType = "rust"
	ProjectTypeGeneric    ProjectType = "generic"
)

type ValidationCommand

type ValidationCommand struct {
	Name        string   `json:"name"`
	Command     string   `json:"command"`
	Args        []string `json:"args"`
	WorkingDir  string   `json:"working_dir"`
	Description string   `json:"description"`
	Required    bool     `json:"required"`
}

ValidationCommand represents a validation command to execute

func BuildValidationCommands

func BuildValidationCommands(projectInfo *ProjectInfo) []ValidationCommand

BuildValidationCommands creates a list of validation commands based on project info

type ValidationIssue

type ValidationIssue struct {
	Line     int    `json:"line"`
	Message  string `json:"message"`
	Severity string `json:"severity"` // "error", "warning", "info"
}

ValidationIssue represents a validation problem found in a file

type ValidationReport

type ValidationReport struct {
	Project        ProjectInfo        `json:"project"`
	ValidationTime time.Time          `json:"validation_time"`
	OverallSuccess bool               `json:"overall_success"`
	CommandResults []CommandResult    `json:"command_results"`
	FileResults    []ValidationResult `json:"file_results"`
	Summary        ValidationSummary  `json:"summary"`
}

ValidationReport represents the complete validation report

func RunValidation

func RunValidation(rootPath string, timeoutSeconds int) (*ValidationReport, error)

RunValidation performs complete validation on a project

type ValidationResult

type ValidationResult struct {
	File         string            `json:"file"`
	IsValid      bool              `json:"is_valid"`
	Issues       []ValidationIssue `json:"issues"`
	ConflictFree bool              `json:"conflict_free"`
}

ValidationResult represents the result of validating a file

func ValidateFile

func ValidateFile(filepath string) (*ValidationResult, error)

ValidateFile performs comprehensive validation on a file

func ValidateRepository

func ValidateRepository() ([]ValidationResult, error)

ValidateRepository performs validation on all relevant files in the repository

type ValidationSummary

type ValidationSummary struct {
	TotalCommands      int `json:"total_commands"`
	SuccessfulCommands int `json:"successful_commands"`
	FailedCommands     int `json:"failed_commands"`
	SkippedCommands    int `json:"skipped_commands"`
	TotalFiles         int `json:"total_files"`
	ValidFiles         int `json:"valid_files"`
	InvalidFiles       int `json:"invalid_files"`
	TotalIssues        int `json:"total_issues"`
	ErrorIssues        int `json:"error_issues"`
	WarningIssues      int `json:"warning_issues"`
}

ValidationSummary provides a summary of validation results

Jump to

Keyboard shortcuts

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