From 8d178c3d6b376259bdc56e49c642a65d9f3f95c4 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 04:26:44 +0000 Subject: [PATCH 1/2] Add pre-commit hooks for linting and formatting - Add .pre-commit-config.yaml with Go-specific hooks - Add .golangci.yml configuration for enhanced linting - Update README.md with development setup instructions - Hooks include gofmt, goimports, go vet, golangci-lint, and general checks Fixes #6 Co-authored-by: Julian LaNeve --- .golangci.yml | 59 +++++++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 39 +++++++++++++++++++++++++++ README.md | 37 ++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 .golangci.yml create mode 100644 .pre-commit-config.yaml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..eb70266 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,59 @@ +run: + timeout: 5m + modules-download-mode: readonly + +linters: + enable: + # Default linters + - errcheck # Check for unchecked errors + - gosimple # Simplify code + - govet # Standard Go vet + - ineffassign # Detect ineffectual assignments + - staticcheck # Many useful static analysis checks + - typecheck # Type checking + - unused # Find unused variables, functions, etc. + + # Additional useful linters + - gofmt # Check formatting + - goimports # Check imports formatting + - misspell # Check for misspelled words + - unconvert # Remove unnecessary conversions + - unparam # Find unused function parameters + - gocritic # Various code quality checks + - gocyclo # Check cyclomatic complexity + - revive # Replacement for golint + + disable: + - deadcode # Deprecated in favor of unused + - varcheck # Deprecated in favor of unused + - structcheck # Deprecated in favor of unused + +linters-settings: + gocyclo: + min-complexity: 15 + + gocritic: + enabled-tags: + - performance + - style + - experimental + disabled-checks: + - whyNoLint # Allow missing linter disable explanations + + revive: + rules: + - name: exported + arguments: [true] + +issues: + exclude-rules: + # Exclude some linters from running on tests files + - path: _test\.go + linters: + - gocyclo + - errcheck + - gosec + + # Maximum number of issues to show + max-issues-per-linter: 0 + max-same-issues: 0 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..002dd1b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +repos: + # Go formatting and imports + - repo: https://github.com/dnephin/pre-commit-golang + rev: v0.5.1 + hooks: + # Format Go code with gofmt + - id: go-fmt + # Organize Go imports + - id: go-imports + # Run go mod tidy + - id: go-mod-tidy + # Run go vet + - id: go-vet-mod + # Build the project to catch compilation errors + - id: go-build-mod + + # Enhanced linting with golangci-lint + - repo: https://github.com/golangci/golangci-lint + rev: v1.54.2 + hooks: + - id: golangci-lint + + # General hooks for all files + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + # Remove trailing whitespace + - id: trailing-whitespace + # Ensure files end with newline + - id: end-of-file-fixer + # Check YAML files are valid + - id: check-yaml + # Check JSON files are valid + - id: check-json + # Check for merge conflict markers + - id: check-merge-conflict + # Prevent committing large files + - id: check-added-large-files + args: ['--maxkb=1000'] \ No newline at end of file diff --git a/README.md b/README.md index b70aa83..edcad75 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,43 @@ sudo mv cwt /usr/local/bin/ 3. **State Tracking**: CWT monitors session status and git changes 4. **TUI Interface**: Real-time dashboard built with terminal UI components +## Development + +### Setting Up Pre-commit Hooks + +This project uses pre-commit hooks to catch linting and formatting issues before they reach CI: + +```bash +# Install pre-commit (one-time setup) +pip install pre-commit + +# Install the git hook scripts +pre-commit install + +# (Optional) Run hooks on all files +pre-commit run --all-files +``` + +### Available Make Targets + +```bash +make help # Show available targets +make test # Run tests +make build # Build binary +make lint # Run golangci-lint (requires installation) +make clean # Clean build artifacts +``` + +### Pre-commit Hooks + +The pre-commit configuration includes: +- **gofmt**: Code formatting +- **goimports**: Import organization +- **go mod tidy**: Dependency management +- **go vet**: Basic linting +- **golangci-lint**: Enhanced linting (see `.golangci.yml`) +- **General checks**: trailing whitespace, file endings, YAML/JSON validation + ## Contributing See [workflows.md](workflows.md) for detailed workflow documentation. From 247ea470ef2225e0e0ee0c8ac39392ec73595de6 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 04:41:12 +0000 Subject: [PATCH 2/2] Remove golangci-lint from pre-commit hooks - Remove golangci-lint hook from .pre-commit-config.yaml - Delete .golangci.yml configuration file - Update README.md to remove golangci-lint references Co-authored-by: Julian LaNeve --- .golangci.yml | 59 ----------------------------------------- .pre-commit-config.yaml | 6 ----- README.md | 3 +-- 3 files changed, 1 insertion(+), 67 deletions(-) delete mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml deleted file mode 100644 index eb70266..0000000 --- a/.golangci.yml +++ /dev/null @@ -1,59 +0,0 @@ -run: - timeout: 5m - modules-download-mode: readonly - -linters: - enable: - # Default linters - - errcheck # Check for unchecked errors - - gosimple # Simplify code - - govet # Standard Go vet - - ineffassign # Detect ineffectual assignments - - staticcheck # Many useful static analysis checks - - typecheck # Type checking - - unused # Find unused variables, functions, etc. - - # Additional useful linters - - gofmt # Check formatting - - goimports # Check imports formatting - - misspell # Check for misspelled words - - unconvert # Remove unnecessary conversions - - unparam # Find unused function parameters - - gocritic # Various code quality checks - - gocyclo # Check cyclomatic complexity - - revive # Replacement for golint - - disable: - - deadcode # Deprecated in favor of unused - - varcheck # Deprecated in favor of unused - - structcheck # Deprecated in favor of unused - -linters-settings: - gocyclo: - min-complexity: 15 - - gocritic: - enabled-tags: - - performance - - style - - experimental - disabled-checks: - - whyNoLint # Allow missing linter disable explanations - - revive: - rules: - - name: exported - arguments: [true] - -issues: - exclude-rules: - # Exclude some linters from running on tests files - - path: _test\.go - linters: - - gocyclo - - errcheck - - gosec - - # Maximum number of issues to show - max-issues-per-linter: 0 - max-same-issues: 0 \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 002dd1b..dfab309 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,12 +14,6 @@ repos: # Build the project to catch compilation errors - id: go-build-mod - # Enhanced linting with golangci-lint - - repo: https://github.com/golangci/golangci-lint - rev: v1.54.2 - hooks: - - id: golangci-lint - # General hooks for all files - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 diff --git a/README.md b/README.md index edcad75..e11d568 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ pre-commit run --all-files make help # Show available targets make test # Run tests make build # Build binary -make lint # Run golangci-lint (requires installation) +make lint # Run basic linting make clean # Clean build artifacts ``` @@ -229,7 +229,6 @@ The pre-commit configuration includes: - **goimports**: Import organization - **go mod tidy**: Dependency management - **go vet**: Basic linting -- **golangci-lint**: Enhanced linting (see `.golangci.yml`) - **General checks**: trailing whitespace, file endings, YAML/JSON validation ## Contributing