Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
47 changes: 47 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# golangci-lint configuration
# Documentation: https://golangci-lint.run/usage/configuration/
version: 2

linters:
enable:
# Default/standard linters
- errcheck # Checks for unchecked errors
- govet # Reports suspicious constructs
- ineffassign # Detects ineffectual assignments
- staticcheck # Comprehensive static analysis
- unused # Checks for unused code

# Additional common linters
- revive # Fast, configurable linter (golint replacement)
- misspell # Finds commonly misspelled English words
- gosec # Inspects for security problems
- bodyclose # Checks HTTP response body is closed
- goconst # Finds repeated strings that could be constants
- gocyclo # Checks cyclomatic complexity

linters-settings:
errcheck:
check-type-assertions: false
check-blank: false

govet:
enable-all: true

gocyclo:
min-complexity: 15 # Standard threshold

gosec:
excludes:
- G104 # Audit errors not checked - covered by errcheck

issues:
exclude-rules:
# Exclude some linters from running on test files
- path: _test\.go
linters:
- gocyclo
- errcheck
- gosec

max-issues-per-linter: 0
max-same-issues: 0
33 changes: 33 additions & 0 deletions main.md
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,39 @@ Download the appropriate archive for your platform from [releases](https://githu
curl -L https://github.com/wham/github-brain/releases/download/v1.2.3/github-brain-darwin-arm64.tar.gz | tar xz
```

## Code Quality

### Linting

Use **golangci-lint** for code quality checks. Configuration in `.golangci.yml`.

**Linters enabled:**
- **errcheck** - Checks for unchecked errors
- **govet** - Reports suspicious constructs
- **ineffassign** - Detects ineffectual assignments
- **staticcheck** - Comprehensive static analysis
- **unused** - Checks for unused code
- **revive** - Fast, configurable linter (golint replacement)
- **misspell** - Finds commonly misspelled English words
- **gosec** - Inspects for security problems
- **bodyclose** - Checks HTTP response body is closed
- **goconst** - Finds repeated strings that could be constants
- **gocyclo** - Checks cyclomatic complexity (threshold: 15)

**Running the linter:**
```bash
# Standalone
golangci-lint run --timeout=5m

# Integrated with build (via scripts/run)
./scripts/run [command]
```

**CI Integration:**
- Linting runs automatically on all PRs via `.github/workflows/build.yml`
- Build fails if linter finds issues (blocking)
- In local development (`scripts/run`), linting runs but is non-blocking to allow rapid iteration

### Release Model

Coded in `.github/workflow/release.yml` and `.github/workflow/build.yml`.
Expand Down
10 changes: 9 additions & 1 deletion scripts/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@
set -e
cd "$(dirname "$0")/.."

# Lint the code (non-blocking in development)
echo "Running linter..."
if command -v golangci-lint &> /dev/null; then
golangci-lint run --timeout=5m || echo "Warning: Linter found issues (non-blocking in development)"
else
echo "Warning: golangci-lint not found, skipping linting"
fi

# Build with FTS5 support enabled
CGO_CFLAGS="-DSQLITE_ENABLE_FTS5" go build -gcflags="all=-N -l" -o ./build/github-brain .
CGO_ENABLED=1 CGO_CFLAGS="-DSQLITE_ENABLE_FTS5" CGO_LDFLAGS="-lm" go build -gcflags="all=-N -l" -o ./build/github-brain .

Copilot AI Dec 22, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of CGO_ENABLED=1 and CGO_LDFLAGS flags appears unrelated to the linting changes described in the PR. This build configuration change should either be mentioned in the PR description or separated into a different PR for clarity.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CGO flags were added to align scripts/run with the CI build configuration (see .github/workflows/build.yml:29). Without CGO_LDFLAGS="-lm", the local build fails with undefined reference to log after linting. This ensures developers can run the full lint+build workflow locally matching CI behavior.


# Set home directory to checkout directory
CHECKOUT_DIR="$(pwd)"
Expand Down
Loading