Skip to content

Switch to glangci lint#1774

Draft
alexbozhenko wants to merge 10 commits intonats-io:mainfrom
alexbozhenko:switch_to_glangci_lint
Draft

Switch to glangci lint#1774
alexbozhenko wants to merge 10 commits intonats-io:mainfrom
alexbozhenko:switch_to_glangci_lint

Conversation

@alexbozhenko
Copy link
Copy Markdown
Member

@alexbozhenko alexbozhenko commented Jan 13, 2025

The server does not install individual linting tools, but lets golangci manage all of the formatting/linting[1]

Since golangci config for jetstream package is a superset of linters that we individually run on the repo root, we can have two separate configs, one basic for the repo root, and one extended just for jetstream.

So it is only one tool to install and version, and all the linters and formatters can be configured in a single file...
https://golangci-lint.run/usage/linters/#govet
https://golangci-lint.run/usage/linters/#misspell
https://golangci-lint.run/usage/formatters/#gofmt
https://golangci-lint.run/usage/linters/#staticcheck

[1]
https://github.com/nats-io/nats-server/blob/v2.11.4/.golangci.yml#L15-L21
https://github.com/nats-io/nats-server/blob/v2.11.4/.github/workflows/tests.yaml#L69-L77

@alexbozhenko alexbozhenko force-pushed the switch_to_glangci_lint branch from e08e58b to 436d9f1 Compare January 13, 2025 22:45
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 13, 2025

Coverage Status

coverage: 84.936% (-0.01%) from 84.949%
when pulling d687021 on alexbozhenko:switch_to_glangci_lint
into 1e1519f on nats-io:main.

running golangci-lint -v shows:
```
level=info msg="[lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused]"
```
so let's enable only extra linters that are currntly configured for js, since config from repo root already has statickcheck and vet
@alexbozhenko alexbozhenko force-pushed the switch_to_glangci_lint branch from 4448930 to d687021 Compare January 14, 2025 05:28
GOFLAGS="-mod=mod -modfile=go_test.mod" staticcheck ./...
find . -type f -name "*.go" | xargs misspell -error -locale US
golangci-lint run --timeout 5m0s ./jetstream/...
GOFLAGS="-mod=mod -modfile=go_test.mod" golangci-lint run -c .golangci.yaml --timeout 5m0s ./...
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably better to use golangci-lint-action instead of shell actions, so that PRs are properly annotated with lint failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants