Skip to content

Commit

Permalink
Update golangci-lint to v1.63.4 (opendatahub-io#1482)
Browse files Browse the repository at this point in the history
* Update golangci-lint to v1.63.4

* Update golangci-lint configuration to remove deprecated linters

* Fix linter findings
  • Loading branch information
lburgazzoli authored Jan 8, 2025
1 parent 4ba3c22 commit 2eea4f1
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ linters:
- forbidigo
- gochecknoglobals # Prevents use of global vars.
- gofumpt
- gomnd # Doesnot allow hardcoded numbers
- gomoddirectives # Doesnot allow replace in go mod file
- mnd
- nestif
Expand All @@ -98,7 +97,6 @@ linters:
- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
- wrapcheck # check if this is required. Prevents direct return of err.
- exportloopref # Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar.
- execinquery # Deprecated upstream. Not applicable since we don't make DB queries.

# Need to check
- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ YQ ?= $(LOCALBIN)/yq
KUSTOMIZE_VERSION ?= v5.0.2
CONTROLLER_GEN_VERSION ?= v0.16.1
OPERATOR_SDK_VERSION ?= v1.31.0
GOLANGCI_LINT_VERSION ?= v1.61.0
GOLANGCI_LINT_VERSION ?= v1.63.4
YQ_VERSION ?= v4.12.2
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.31.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ package datasciencecluster
import (
"context"
"fmt"
"slices"
"strings"

operatorv1 "github.com/openshift/api/operator/v1"
conditionsv1 "github.com/openshift/custom-resource-status/conditions/v1"
"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func MergeDeployments(source *unstructured.Unstructured, target *unstructured.Un
r = make(map[string]interface{})
}

//nolint:forcetypeassert
//nolint:forcetypeassert,errcheck
resources[name.(string)] = r
}

Expand All @@ -74,12 +74,13 @@ func MergeDeployments(source *unstructured.Unstructured, target *unstructured.Un
continue
}

//nolint:errcheck
nr, ok := resources[name.(string)]
if !ok {
continue
}

//nolint:forcetypeassert
//nolint:forcetypeassert,errcheck
if len(nr.(map[string]interface{})) == 0 {
delete(m, "resources")
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"context"
"fmt"
"io/fs"
"maps"
"strings"
gt "text/template"

"golang.org/x/exp/maps"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/serializer"

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/reconciler/reconciler_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"

"github.com/hashicorp/go-multierror"
"golang.org/x/exp/slices"
"k8s.io/apimachinery/pkg/runtime/schema"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ import (
"errors"
"fmt"
"io"
"maps"
"net/http"
"os"
"path/filepath"
"strings"

"golang.org/x/exp/maps"
k8serr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
6 changes: 3 additions & 3 deletions pkg/feature/servicemesh/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ func CheckControlPlaneComponentReadiness(ctx context.Context, c client.Client, s
return false, fmt.Errorf("status conditions not found or error in parsing of Service Mesh Control Plane: %w", err)
}

readyComponents := len(components["ready"].([]interface{})) //nolint:forcetypeassert
pendingComponents := len(components["pending"].([]interface{})) //nolint:forcetypeassert
unreadyComponents := len(components["unready"].([]interface{})) //nolint:forcetypeassert
readyComponents := len(components["ready"].([]interface{})) //nolint:forcetypeassert,errcheck
pendingComponents := len(components["pending"].([]interface{})) //nolint:forcetypeassert,errcheck
unreadyComponents := len(components["unready"].([]interface{})) //nolint:forcetypeassert,errcheck

return pendingComponents == 0 && unreadyComponents == 0 && readyComponents > 0, nil
}
4 changes: 2 additions & 2 deletions pkg/manifests/kustomize/kustomize_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package kustomize

import (
"fmt"
"maps"
"path/filepath"
"slices"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/kustomize/api/krusty"
"sigs.k8s.io/kustomize/kyaml/filesys"
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"errors"
"fmt"
"io"
"slices"

"github.com/davecgh/go-spew/spew"
routev1 "github.com/openshift/api/route/v1"
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/gc/gc_support.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package gc

import (
"slices"
"sync"

"golang.org/x/exp/slices"
authorizationv1 "k8s.io/api/authorization/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"os"
"slices"
"strings"
"testing"

Expand All @@ -13,7 +14,6 @@ import (
ofapi "github.com/operator-framework/api/pkg/operators/v1alpha1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
autoscalingv1 "k8s.io/api/autoscaling/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func ensureServicemeshOperators(t *testing.T, tc *testContext) error { //nolint:
}(op)
}

for range len(ops) {
for range ops {
err := <-c
errors = multierror.Append(errors, err)
}
Expand Down

0 comments on commit 2eea4f1

Please sign in to comment.