mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 07:02:09 +01:00
Expands the pre-commit configuration with a wider range of hooks to enforce file quality, validation, security, and Git safety checks. The CI pipeline is updated to: - Correct the `golangci-lint` format command to `fmt`. - Enable CGO for test execution to support the race detector. - Improve the robustness of test report parsing scripts. Additionally, this commit includes minor stylistic and formatting cleanups across various project files.
2.2 KiB
2.2 KiB
Agent Guidelines for articulate-parser
Build/Test Commands
- Build:
task buildorgo build -o bin/articulate-parser main.go - Run tests:
task testorgo test -race -timeout 5m ./... - Run single test:
go test -v -race -run ^TestName$ ./path/to/package - Test with coverage:
task test:coverageorgo test -race -coverprofile=coverage/coverage.out -covermode=atomic ./...
- Lint:
task lint(runs vet, fmt check, staticcheck, golangci-lint) - Format:
task fmtorgofmt -s -w . - CI checks:
task ci(deps, lint, test with coverage, build)
Code Style Guidelines
Imports
- Use
goimportswith local prefix:github.com/kjanat/articulate-parser - Order: stdlib, external, internal packages
- Group related imports together
Formatting
- Use
gofmt -s(simplify) andgofumptwith extra rules - Function length: max 100 lines, 50 statements
- Cyclomatic complexity: max 15
- Cognitive complexity: max 20
Types & Naming
- Use interface-based design (see
internal/interfaces/) - Export types/functions with clear godoc comments ending with period
- Use descriptive names:
ArticulateParser,MarkdownExporter - Receiver names: short (1-2 chars), consistent per type
Error Handling
- Always wrap errors with context:
fmt.Errorf("operation failed: %w", err) - Use
%wverb for error wrapping to preserve error chain - Check all error returns (enforced by
errcheck) - Document error handling rationale in defer blocks when ignoring close errors
Comments
- All exported types/functions require godoc comments
- End sentences with periods (
godotlinter enforced) - Mark known issues with TODO/FIXME/HACK/BUG/XXX
Security
- Use
#nosecwith justification for deliberate security exceptions (G304 for CLI file paths, G306 for export file permissions) - Run
gosecandgovulncheckfor security audits
Testing
- Enable race detection:
-raceflag - Use table-driven tests where applicable
- Mark test helpers with
t.Helper() - Benchmarks in
*_bench_test.go, examples in*_example_test.go
Dependencies
- Minimal external dependencies (currently: go-docx, golang.org/x/net, golang.org/x/text)
- Run
task deps:tidyafter adding/removing dependencies