Commit Graph

23 Commits

Author SHA1 Message Date
Anders Eknert e03ac2f200 Bump golangci-lint, more gocritic linters (#8052)
- Bump golangci-lint -> 2.6.2
- Fix all `deprecatedComment` "notices should be in a dedicated paragraph, separated from the rest" reports
- Enable `appendCombine` and fix all "appendCombine: can combine chain of X appends into one" notices
- Enable `preferFprint` and fix the few reported issues
- Fix various issues reported only once or twice, like `zeroByteRepeat`

Signed-off-by: Anders Eknert <anders.eknert@apple.com>
2025-11-17 11:08:39 +01:00
Sebastian Spaink 8c0079f551 Bump golangci-lint to v2.4.0 (#7878)
Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
2025-09-03 15:21:30 -05:00
lestrrat b08a1df858 Upgrade interned jwx (0.9.x) with github.com/lestrrat-go/jwx/v3 (#7733)
Fixes: #7638

Signed-off-by: Daisuke Maki <lestrrat+github@gmail.com>
2025-08-04 16:41:09 +02:00
robmyersrobmyers 7dd0dceb6d refactor: Remove internal/gqlparser and use upstream instead. (#7538)
This updates gqlparser from version ~v2.5.1 and the June 2018 GraphQL spec to
v2.5.26 and the October 2021 GraphQL spec.

Signed-off-by: Rob Myers <1243316+robmyersrobmyers@users.noreply.github.com>
2025-05-05 11:11:27 -05:00
Anders Eknert bd5ceb5142 Enable unused-receiver linter (revive) (#7448)
Signed-off-by: Anders Eknert <anders@styra.com>
2025-03-14 11:41:25 +01:00
Anders Eknert afb30d3f9d Add gocritic linter, fix a bunch of stuff (#7377)
Brace yourselves! For there are many touched files here. No changes
in semantics however.

Spent a long time trying out the various optional rules gocritic
provides, and settled for a few of them. There are more I really
like, but that would take many hours to address across the codebase.

Perhaps others find gocritic too pedantic? If so, we can merge the
fixes without enabling the rule.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-02-24 16:28:41 +01:00
Anders Eknert 58c7d7aff2 Bump golangci-lint -> 1.64.5 (#7374)
Also:
- Replace deprecated tenv linter with usetesting, and address
  the issues it reported (nice!)

Signed-off-by: Anders Eknert <anders@styra.com>
2025-02-19 10:29:17 +01:00
Anders Eknert da69c32819 Add nilness linter from govet (#7335)
Seeing @thevilledev adding this in conftest, and thinking we
had it here already. We didn't! Fixing the two issues it reported
where we checked for conditions that couldn't possibly be met.

Signed-off-by: Anders Eknert <anders@styra.com>
2025-02-01 10:37:53 +01:00
Anders Eknert 55e87e79ae Add perfsprint linter (#7334)
And update code to conform to the rule.

- Replace unnecessary fmt.Sprintf with string concatenation
- Replace fmt.Sprint with more efficient strconv.Itoa
- Replace static fmt.Errorf calls with more efficient errors.New

Thanks @srenatus for pushing me down this rabbit hole!

Signed-off-by: Anders Eknert <anders@styra.com>
2025-01-31 20:24:05 +01:00
Anders Eknert b942136a4a Use Go 1.22+ int ranges (#7328)
With "some" help from `golangci-lint run --fix ./...`

Signed-off-by: Anders Eknert <anders@styra.com>
2025-01-30 09:57:27 +01:00
Anders Eknert e682a67792 Don't use reflect.DeepEqual for errors (#7311)
I pushed most of these fixed previously but these ones required
more work. Probably more work that it was worth, lol, but now the
work is done... and at least we can add this to the list of enabled
checks.

Fixes #7238

Signed-off-by: Anders Eknert <anders@styra.com>
2025-01-24 20:00:06 +01:00
Eng Zer Jun 79ce575893 golangci: fix invalid linter-settings configuration name (#7244)
* golangci: fix invalid `linter-settings` configuration name

`linters-settings` is the correct configuration name [1].

[1]: https://golangci-lint.run/usage/configuration/#linters-settings-configuration

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* golangci: remove misspell US locale restriction

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

---------

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2025-01-04 19:52:40 +00:00
Johan Fylling a179a24c48 v1 API
All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.

Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.

Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:27:34 +01:00
Anders Eknert 270f31f6af Avoid copying loop vars (Go 1.22+) (#7191)
This isn't needed anymore, so now we don't.
Also enabled the copyloopvar linter in case we
accidentally do this in the future.

Signed-off-by: Anders Eknert <anders@styra.com>
2024-11-24 20:51:38 +01:00
Stephan Renatus 20885fe4a9 golangci: bump version, addess all new findings
The previous version has been failing without any good reason for me,
so let's try this.

About the version pick: It's not the latest version (v1.62.0 at the
moment), because that would introduce a new revive rule,
redeclares-builtin-id, and that flags every variable called `min` or
`max` in the code base. I had started addressing these, but they were
just too many.

The new issues related to this version are mostly that it complains
whenever it finds a non-static string that makes its way into a printf-
like function. However, that's a common pattern in some place here, so
I've sprinkled some nolint:govet on it.

Signed-off-by: Stephan Renatus <stephan@styra.com>
2024-11-14 20:36:50 +01:00
Anders Eknert af8f915846 Add mirror linter
This flags unnecessary conversions of byte->string and vice versa

Signed-off-by: Anders Eknert <anders@eknert.com>
2024-09-26 13:45:37 -07:00
yanggang 38d446bc01 ci: remove deprecated linters in golangci config (#5530)
Signed-off-by: yanggang <gang.yang@daocloud.io>
2023-01-04 09:35:39 +01:00
Anders Eknert 50d4e31d6b chore: Use t.Setenv in tests (#5321)
And enable the `tenv` linter for the future.

Also, bump version of golangci-lint and fix some new
warnings that came from that.

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-10-27 17:44:56 +02:00
Anders Eknert 95708108f3 linters: add unconvert (#5318)
Got a few warnings from my IDE about redundant type conversions,
so I decided to look into it. Added the unconvert linter to our
checks, and fixed the violations. Added two ignore comments as I
wasn't sure about whether they'd change the semantics of the code.

Signed-off-by: Anders Eknert <anders@eknert.com>
2022-10-27 13:35:39 +02:00
Philip Conrad b2d92a33c1 Add prealloc linter check + linter fixes (#5139)
This commit adds the `prealloc` linter to the list of linters for OPA, and fixes up the miscellaneous locations in the code that the linter found where we could easily preallocate slices.

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
2022-09-15 15:09:54 -04:00
Stephan Renatus 7b39b96633 misc: disable goconst linter, remove nolint in internal/compiler (#3585)
* golangci-lint: remove goconst linter

We've debated turning it to 10, or removing it alltogether; landed
at the fact that if the number of occurrences really is 10+, it'll
be noted in code review anyways.

* internal/compiler/wasm: more selectively disable deadcode/varcheck linter

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
2021-06-24 12:37:02 +02:00
Will Beason 1281473250 Run dockerized golangci-lint
This means that "make lint" will work the same for everyone and the
workflow without additional coordination. Before this PR, it was
possible for maintainers to be on a different version of golangci-lint
than the one used by the GitHub workflow and so "make check" would
provide inconsistent results.

Also add timeout to configuration so we don't time out.`

Signed-off-by: Will Beason <willbeason@google.com>
2021-06-03 16:09:02 -04:00
Will Beason 3be1d08b87 Change check-lint to use golangci-lint (#3465)
golint is deprecated. The author of the code no longer supports the
codebase. golangci-lint is faster than golint, and is in use by other
opa repositories (e.g. Gatekeeper).

This commit changes tools.go to reference golangci (so it ends up in
vendor) and modifies check-lint to use golangci instead.

Breaking API Changes:

- plugins/rest/rest.go: Fix typo "AllowInsureTLS" -> "AllowInsecureTLS"
- storage/errors.go: Removed unused IndexingNotSupportedErr

Signed-off-by: Will Beason <willbeason@google.com>
2021-05-19 07:52:02 +02:00