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

Update golint configuration #3502

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ linters:
- ineffassign
- misspell
- bodyclose
- errorlint
disable-all: true

linters-settings:
errorlint:
errorf: true
errorf-multi: false
asserts: false
comparison: false

issues:
exclude-rules:
- linters:
Expand Down
2 changes: 1 addition & 1 deletion cmd/ci-operator/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func verifyMetadata(jobSpec *api.JobSpec, namespace string, customMetadata map[s
errs = append(errs, ioutil.WriteFile(filepath.Join(testArtifactDirectory, "d-ignore1.txt"), []byte(``), os.FileMode(0644)))
errs = append(errs, ioutil.WriteFile(filepath.Join(testArtifactDirectory, "e-ignore1.txt"), []byte(`{"invalid-field2": "invalid-value2"}`), os.FileMode(0644)))
if err := utilerrors.NewAggregate(errs); err != nil {
return fmt.Errorf("one or more of the empty *ignore files failed to write: %v", err)
return fmt.Errorf("one or more of the empty *ignore files failed to write: %w", err)
}

if err := o.writeMetadataJSON(); err != nil {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ require (
github.com/openshift/openshift-apiserver v0.0.0-alpha.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349
github.com/prometheus/client_golang v1.15.1
github.com/prometheus/client_model v0.4.0
github.com/prometheus/common v0.44.0
Expand Down
3 changes: 0 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,6 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349 h1:Kq/3kL0k033ds3tyez5lFPrfQ74fNJ+OqCclRipubwA=
github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/pquerna/cachecontrol v0.1.0/go.mod h1:NrUG3Z7Rdu85UNR3vm7SOsl1nFIeSiQnrHV5K9mBcUI=
Expand Down Expand Up @@ -1728,7 +1726,6 @@ golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand Down
27 changes: 18 additions & 9 deletions hack/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ if [[ $HOME = '/' ]]; then
export HOME=/tmp
fi

# We embedd this so it must exist for compilation to succeed, but it's not checked in
# We embed this so it must exist for compilation to succeed, but it's not checked in
if [[ -n ${CI:-} ]]; then touch cmd/vault-secret-collection-manager/index.js; fi

golangci-lint run --build-tags e2e,e2e_framework,optional_operators
GOLANGCI_LINT_ARGS="--build-tags=e2e,e2e_framework,optional_operators"

cd $(dirname $0)/..
if [[ -n ${CI:-} ]];
then
golangci-lint run "$GOLANGCI_LINT_ARGS"
else
DOCKER=${DOCKER:-podman}

# Make sure the failing linter doesn't make the command fail and hence the script pass because we don't enter
# the condition.
set +o pipefail
if go run ./vendor/github.com/polyfloyd/go-errorlint -errorf ./... 2>&1 \
|grep 'non-wrapping format verb for fmt.Errorf'; then
exit 1
if ! which "$DOCKER" > /dev/null 2>&1;
then
echo "$DOCKER not found, please install."
exit 1
fi

$DOCKER run --rm \
--volume "${PWD}:/go/src/github.com/openshift/ci-tools:z" \
--workdir /go/src/github.com/openshift/ci-tools \
docker.io/golangci/golangci-lint:v1.48.0 \
golangci-lint run "$GOLANGCI_LINT_ARGS"
fi
2 changes: 0 additions & 2 deletions hack/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package hack

// Add tools that hack scripts depend on here, to ensure they are vendored.
import (
_ "github.com/polyfloyd/go-errorlint"

_ "sigs.k8s.io/controller-tools/cmd/controller-gen"

_ "github.com/openshift-eng/openshift-goimports"
Expand Down
2 changes: 1 addition & 1 deletion pkg/backporter/backporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func handleError(w http.ResponseWriter, err error, shortErrorMessage string, sta
_, fprintfErr = fmt.Fprintf(w, "failed while building error page")
}
metrics.RecordError(shortErrorMessage, m.ErrorRate)
logrus.WithFields(logFieldsFor(endpoint, bugID)).WithError(fmt.Errorf("%s: %v", shortErrorMessage, utilerrors.NewAggregate([]error{err, wpErr, fprintfErr}))).Error("an error occurred")
logrus.WithFields(logFieldsFor(endpoint, bugID)).WithError(fmt.Errorf("%s: %w", shortErrorMessage, utilerrors.NewAggregate([]error{err, wpErr, fprintfErr}))).Error("an error occurred")
}

// HandlerFuncWithErrorReturn allows returning errors to be logged
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/polyfloyd/go-errorlint/.gitignore

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/polyfloyd/go-errorlint/LICENSE

This file was deleted.

86 changes: 0 additions & 86 deletions vendor/github.com/polyfloyd/go-errorlint/README.md

This file was deleted.

143 changes: 0 additions & 143 deletions vendor/github.com/polyfloyd/go-errorlint/errorlint/allowed.go

This file was deleted.

Loading