Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to glangci lint #1774

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

alexbozhenko
Copy link
Contributor

@alexbozhenko alexbozhenko commented Jan 13, 2025

Just checking to see if this will work...

The server does not install separate 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/linters/#gofmt
https://golangci-lint.run/usage/linters/#staticcheck

[1]
https://github.com/nats-io/nats-server/blob/e485bfa816d7c62b687df23447ac28784f5b4f38/.golangci.yml#L17-L29
https://github.com/nats-io/nats-server/blob/e485bfa816d7c62b687df23447ac28784f5b4f38/.github/workflows/tests.yaml#L25-L31

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

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
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