Skip to content

Commit

Permalink
Update depguard configuration for golangci-lint v1.53
Browse files Browse the repository at this point in the history
The depguard v2 linter allows different rules to be applied to different
sets of files.

See: golangci/golangci-lint#3795
See: https://github.com/OpenPeeDeeP/depguard#config
See: https://golangci-lint.run/usage/linters/#depguard
  • Loading branch information
cbandy committed Jun 5, 2023
1 parent 7c46037 commit d988118
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,25 @@ linters:

linters-settings:
depguard:
include-go-root: true
packages-with-error-message:
- io/ioutil: >
Use the "io" and "os" packages instead.
See https://go.dev/doc/go1.16#ioutil
rules:
everything:
deny:
- pkg: io/ioutil
desc: >
Use the "io" and "os" packages instead.
See https://go.dev/doc/go1.16#ioutil
- net/http/httptest: Should be used only in tests.
- testing/*: The "testing" packages should be used only in tests.
not-tests:
files: ['!$test']
deny:
- pkg: net/http/httptest
desc: Should be used only in tests.

- github.com/crunchydata/postgres-operator/internal/testing/*: >
The "internal/testing" packages should be used only in tests.
- pkg: testing/*
desc: The "testing" packages should be used only in tests.

- pkg: github.com/crunchydata/postgres-operator/internal/testing/*
desc: The "internal/testing" packages should be used only in tests.

exhaustive:
default-signifies-exhaustive: true
Expand Down Expand Up @@ -60,14 +68,6 @@ linters-settings:
alias: apierrors
no-unaliased: true

issues:
exclude-rules:
# These testing packages are allowed in test files. The packages are
# disallowed everywhere then ignored here because that is how depguard works.
- linters: [depguard]
path: _test[.]go$
text: \`(net/http/httptest|[^`]*testing[^`]*)`

run:
build-tags:
- envtest
Expand Down

0 comments on commit d988118

Please sign in to comment.