Add how-to-lint rules to README-dev.md and CLAUDE.md (#2175)

This commit is contained in:
John Kerl 2026-07-07 15:00:29 -04:00 committed by GitHub
parent e0ed7e469c
commit 06eb706055
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 2 deletions

View file

@ -28,6 +28,24 @@ staticcheck -version
If this works, you can use `make staticcheck` without any further setup. If this works, you can use `make staticcheck` without any further setup.
### Setting Up golangci-lint
CI runs `golangci-lint` (config in `.golangci.yml`) on every push and PR via
`.github/workflows/golangci-lint.yml`. To run it locally, install the version
matching CI (currently v2.12.2) per the
[official instructions](https://golangci-lint.run/welcome/install/#local-installation), e.g.:
```bash
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.12.2
```
This also installs to `~/go/bin/`, so the same `PATH` addition above covers it.
**Verify the installation:**
```bash
golangci-lint --version
```
## Build & Test ## Build & Test
### Building ### Building
@ -48,8 +66,14 @@ make bench # Run benchmarks
```bash ```bash
make fmt # Format code with go fmt make fmt # Format code with go fmt
make staticcheck # Run static analysis (see Initial Setup section above) make staticcheck # Run static analysis (see Initial Setup section above)
make lint # Run golangci-lint, same invocation as CI (see Initial Setup section above)
``` ```
`make lint` runs `golangci-lint run ./cmd/mlr ./pkg/...`, matching
`.github/workflows/golangci-lint.yml` exactly, so a clean local run means CI's
lint job will pass too. It is not part of `make check` or `make dev`, so run
it explicitly before pushing.
### Full Developer Workflow ### Full Developer Workflow
```bash ```bash
make dev # Format, build, test, generate docs (comprehensive check before pushing) make dev # Format, build, test, generate docs (comprehensive check before pushing)
@ -125,9 +149,10 @@ Documentation is built from `.md.in` template files that contain live code sampl
Always run: Always run:
```bash ```bash
make dev make dev
make lint
``` ```
This ensures code formatting, builds successfully, passes all tests, and documentation is up to date. `make dev` ensures code formatting, builds successfully, passes all tests, and documentation is up to date. `make lint` is separate (not part of `make dev`/`make check`) and mirrors the CI lint job.
## Additional Resources ## Additional Resources

View file

@ -79,6 +79,11 @@ fmt format:
staticcheck: staticcheck:
staticcheck ./pkg/... ./cmd/mlr/... staticcheck ./pkg/... ./cmd/mlr/...
# Needs first: https://golangci-lint.run/welcome/install/#local-installation
# Config lives in .golangci.yml; same invocation as .github/workflows/golangci-lint.yml
lint:
golangci-lint run ./cmd/mlr ./pkg/...
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# For developers before pushing to GitHub. # For developers before pushing to GitHub.
# #
@ -125,4 +130,4 @@ release_tarball release-tarball: build check
# ================================================================ # ================================================================
# Go does its own dependency management, outside of make. # Go does its own dependency management, outside of make.
.PHONY: build mlr check unit_test regression_test bench fmt staticcheck dev docs man .PHONY: build mlr check unit_test regression_test bench fmt staticcheck lint dev docs man

View file

@ -1,6 +1,7 @@
# Quickstart for developers # Quickstart for developers
* `make`, `make check`, `make docs`, etc: see [Makefile](Makefile) in the repo base directory. * `make`, `make check`, `make docs`, etc: see [Makefile](Makefile) in the repo base directory.
* Linting: `make lint` runs [golangci-lint](https://golangci-lint.run/) (config in [.golangci.yml](.golangci.yml)) with the same invocation used by [.github/workflows/golangci-lint.yml](.github/workflows/golangci-lint.yml), so a clean local run means CI's lint job will pass too. Install golangci-lint locally per the [official instructions](https://golangci-lint.run/welcome/install/#local-installation) (match the CI version, currently v2.12.2). It's a separate step from `make dev`/`make check` -- run it explicitly before pushing. `make staticcheck` (requires [staticcheck](https://staticcheck.io)) is a second, independent static-analysis pass.
* Software-testing methodology: see [./test/README.md](./test/README.md). * Software-testing methodology: see [./test/README.md](./test/README.md).
* Source-code indexing: please see [https://sourcegraph.com/github.com/johnkerl/miller](https://sourcegraph.com/github.com/johnkerl/miller) * Source-code indexing: please see [https://sourcegraph.com/github.com/johnkerl/miller](https://sourcegraph.com/github.com/johnkerl/miller)
* Godoc As of September 2021, `godoc` support is minimal: package-level synopses exist; most `func`/`const`/etc content lacks `godoc`-style comments. To view doc material, you can: * Godoc As of September 2021, `godoc` support is minimal: package-level synopses exist; most `func`/`const`/etc content lacks `godoc`-style comments. To view doc material, you can: