From d9881189da01e8c0ff30da76dcc8b578b9bd66b5 Mon Sep 17 00:00:00 2001 From: Chris Bandy Date: Mon, 5 Jun 2023 12:10:11 -0500 Subject: [PATCH] Update depguard configuration for golangci-lint v1.53 The depguard v2 linter allows different rules to be applied to different sets of files. See: https://github.com/golangci/golangci-lint/issues/3795 See: https://github.com/OpenPeeDeeP/depguard#config See: https://golangci-lint.run/usage/linters/#depguard --- .golangci.yaml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 7b9c27b748..fb1ee2ceaf 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -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 @@ -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