Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 80 additions & 50 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,85 +48,115 @@ The codebase uses extensive object pooling for performance optimization:

## Development Commands

This project uses [Task](https://taskfile.dev) as the task runner. Install with:
```bash
go install github.com/go-task/task/v3/cmd/task@latest
# Or: brew install go-task (macOS)
```

### Building and Testing
```bash
# Build the project
make build
go build -v ./...
# Show all available tasks
task

# Build all packages
task build

# Build the CLI tool
go build -o gosqlx ./cmd/gosqlx
# Build the CLI binary
task build:cli

# Build CLI for all platforms
task build:cli:all

# Install CLI globally
task install

# Run all tests
make test
go test -v ./...
task test

# Run a single test by pattern
go test -v -run TestTokenizer_SimpleSelect ./pkg/sql/tokenizer/
go test -v -run TestParser_.*Window.* ./pkg/sql/parser/
# Run tests with race detection (CRITICAL)
task test:race

# Run tests for specific packages
go test -v ./pkg/sql/tokenizer/
go test -v ./pkg/sql/parser/
go test -v ./pkg/sql/ast/
go test -v ./pkg/models/
go test -v ./pkg/errors/
# Run tests for specific package
task test:pkg PKG=./pkg/sql/parser

# Run tests in short mode
task test:short

# Run tests with coverage report
make coverage
go test -cover -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
task coverage

# Generate text coverage report for specific package
go test -coverprofile=coverage.out ./pkg/models/
go tool cover -func=coverage.out
# Show coverage by function
task coverage:func

# Run benchmarks
go test -bench=. -benchmem ./...
go test -bench=BenchmarkTokenizer -benchmem ./pkg/sql/tokenizer/
go test -bench=BenchmarkParser -benchmem ./pkg/sql/parser/
task bench

# Run benchmarks with CPU profiling
task bench:cpu

# Run fuzz tests
task fuzz
```

### Code Quality
```bash
# Format code
make fmt
go fmt ./...
task fmt

# Check formatting (fails if not formatted)
task fmt:check

# Run go vet
task vet

# Run golangci-lint
task lint

# Vet code
make vet
go vet ./...
# Run golangci-lint with auto-fix
task lint:fix

# Run linting (requires golint installation)
make lint
golint ./...
# Run staticcheck
task staticcheck

# Run all quality checks
make quality
# Run all quality checks (fmt, vet, lint)
task quality

# Full check suite (format, vet, lint, test:race)
task check

# CRITICAL: Always run race detection during development
go test -race ./...
go test -race -benchmem ./...
go test -race -timeout 30s ./pkg/...
task test:race
```

### Running Examples
### Security
```bash
# Run security vulnerability scan
task security:scan

# Validate security setup
task security:validate
```

### CI/CD
```bash
# Basic example (demonstrates tokenization and parsing)
cd examples/cmd/
go run example.go
# Run full CI pipeline
task ci

# SQL validator example
cd examples/sql-validator/
go run main.go
# Quick CI check (no race detection)
task ci:quick
```

# SQL formatter example
cd examples/sql-formatter/
go run main.go
### Running Examples
```bash
# Run basic example
task examples

# Run example tests
cd examples/cmd/
go test -v example_test.go
task examples:test

# Or run directly:
go run ./examples/cmd/example.go
```

### CLI Tool Usage (v1.4.0+)
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ GoSQLX aims to be the **fastest, most reliable, and most comprehensive SQL parsi
### Prerequisites
- **Go 1.19+** (latest stable version recommended)
- **Git** for version control
- **Make** for build automation (optional)
- **Task** for task automation (optional) - Install with `go install github.com/go-task/task/v3/cmd/task@latest`

### Getting Started
```bash
Expand All @@ -60,7 +60,7 @@ go test ./...
go test -race ./...

# 7. Install Git hooks (RECOMMENDED)
make install-hooks
task hooks:install
# or
./scripts/install-hooks.sh
```
Expand All @@ -70,8 +70,8 @@ make install-hooks
GoSQLX provides pre-commit hooks to catch code quality issues before they reach CI/CD:

```bash
# Install hooks using Make
make install-hooks
# Install hooks using Task
task hooks:install

# Or run the script directly
./scripts/install-hooks.sh
Expand Down Expand Up @@ -393,7 +393,7 @@ Many applications use PostgreSQL's JSON features extensively...
## 📋 Pull Request Checklist

### Before Submitting
- [ ] **Git Hooks**: Pre-commit hooks installed and passing (`make install-hooks`)
- [ ] **Git Hooks**: Pre-commit hooks installed and passing (`task hooks:install`)
- [ ] **Tests**: All tests pass with `go test -race ./...`
- [ ] **Coverage**: New code has >95% test coverage
- [ ] **Performance**: No performance regression
Expand Down
69 changes: 0 additions & 69 deletions Makefile

This file was deleted.

51 changes: 37 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,39 +691,62 @@ GoSQLX/
### Prerequisites

- Go 1.19+
- Make (optional, for Makefile targets)
- golint, staticcheck (for code quality)
- [Task](https://taskfile.dev) - task runner (install: `go install github.com/go-task/task/v3/cmd/task@latest`)
- golangci-lint, staticcheck (for code quality, install: `task deps:tools`)

### Task Runner

This project uses [Task](https://taskfile.dev) as the task runner. Install with:
```bash
go install github.com/go-task/task/v3/cmd/task@latest
# Or: brew install go-task (macOS)
```

### Building

```bash
# Show all available tasks
task

# Build the project
make build
task build

# Run quality checks
make quality
# Build the CLI binary
task build:cli

# Install CLI globally
task install

# Run all quality checks
task quality

# Run all tests
make test
task test

# Run tests with race detection (recommended)
task test:race

# Clean build artifacts
make clean
task clean
```

### Code Quality

```bash
# Format code
go fmt ./...
task fmt

# Run go vet
task vet

# Vet code
go vet ./...
# Run golangci-lint
task lint

# Run linter
golint ./...
# Run all quality checks (fmt, vet, lint)
task quality

# Static analysis
staticcheck ./...
# Full CI check (format, vet, lint, test:race)
task check
```

## 🤝 Contributing
Expand Down
Loading
Loading