Skip to content

Commit

Permalink
Fix linting issues with new golangci-lint version
Browse files Browse the repository at this point in the history
  • Loading branch information
johscheuer committed Jan 22, 2025
1 parent 3c16099 commit 4ecb27c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ linters:
- dogsled
- errcheck
- errorlint
- exportloopref
- copyloopvar
# - goconst
# - gocritic
# - gocyclo
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CONTROLLER_GEN_PKG?=sigs.k8s.io/controller-tools/cmd/[email protected]
CONTROLLER_GEN=$(GOBIN)/controller-gen
KUSTOMIZE_PKG?=sigs.k8s.io/kustomize/kustomize/[email protected]
KUSTOMIZE=$(GOBIN)/kustomize
GOLANGCI_LINT_PKG=github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
GOLANGCI_LINT_PKG=github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
GOLANGCI_LINT=$(GOBIN)/golangci-lint
GORELEASER_PKG=github.com/goreleaser/[email protected]
GORELEASER=$(GOBIN)/goreleaser
Expand Down
3 changes: 2 additions & 1 deletion api/v1beta2/foundationdbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta2

import (
"errors"
"fmt"
"k8s.io/apimachinery/pkg/util/intstr"
"math"
Expand Down Expand Up @@ -2918,7 +2919,7 @@ func (cluster *FoundationDBCluster) Validate() error {
return nil
}

return fmt.Errorf(strings.Join(validations, ", "))
return errors.New(strings.Join(validations, ", "))
}

// IsTaintFeatureDisabled return true if operator is configured to not replace Pods tainted Nodes OR
Expand Down
16 changes: 0 additions & 16 deletions e2e/fixtures/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,22 +517,6 @@ func (config *ClusterConfig) CalculateRoleCounts() fdbv1beta2.RoleCounts {
return roleCounts
}

func max(a int, b int) int {
if a > b {
return a
}

return b
}

func min(a int, b int) int {
if a < b {
return a
}

return b
}

func calculateProxies(proxies int) (int, int) {
// This calculation is only a rough estimate and can change based on the workload.
// Use 1/4 of the proxies for GRV or at max 4 processes
Expand Down
12 changes: 4 additions & 8 deletions e2e/fixtures/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func Unprintable(val string) ([]byte, error) {
if c == '\\' {
i++
if i == len(val) {
return nil, fmt.Errorf(fmt.Sprintf("end after one \\ when unprint [%s]", val))
return nil, fmt.Errorf("end after one \\ when unprint [%s]", val)
}
switch val[i] {
case '\\':
Expand All @@ -497,9 +497,7 @@ func Unprintable(val string) ([]byte, error) {
case 'x':
{
if i+2 >= len(val) {
return nil, fmt.Errorf(
fmt.Sprintf("not have two chars after \\x when unprint [%s]", val),
)
return nil, fmt.Errorf("not have two chars after \\x when unprint [%s]", val)
}
d1, err := unhex(val[i+1])
if err != nil {
Expand All @@ -514,9 +512,7 @@ func Unprintable(val string) ([]byte, error) {
}
default:
{
return nil, fmt.Errorf(
fmt.Sprintf("after \\ it's neither \\ nor x when unprint %s", val),
)
return nil, fmt.Errorf("after \\ it's neither \\ nor x when unprint %s", val)
}
}
} else {
Expand All @@ -538,5 +534,5 @@ func unhex(c byte) (int, error) {
return int(c - 'A' + 10), nil
}

return -1, fmt.Errorf(fmt.Sprintf("failed to unhex %x", c))
return -1, fmt.Errorf("failed to unhex %x", c)
}
5 changes: 3 additions & 2 deletions kubectl-fdb/cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package cmd

import (
"encoding/json"
"errors"
"fmt"
"strings"
"time"
Expand Down Expand Up @@ -158,7 +159,7 @@ func newAnalyzeCmd(streams genericclioptions.IOStreams) *cobra.Command {
errMsg.WriteString(err.Error())
}

return fmt.Errorf(errMsg.String())
return errors.New(errMsg.String())
}

return nil
Expand Down Expand Up @@ -219,7 +220,7 @@ func allConditionsValid(conditions []string) error {
return nil
}

return fmt.Errorf(errString.String())
return errors.New(errString.String())
}

func analyzeCluster(cmd *cobra.Command, kubeClient client.Client, cluster *fdbv1beta2.FoundationDBCluster, autoFix bool, wait bool, ignoreConditions []string, ignoreRemovals bool) error {
Expand Down
4 changes: 2 additions & 2 deletions kubectl-fdb/cmd/buggify_crash_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newBuggifyCrashLoop(streams genericclioptions.IOStreams) *cobra.Command {
if err != nil {
return err
}
clear, err := cmd.Flags().GetBool("clear")
clearFlag, err := cmd.Flags().GetBool("clear")
if err != nil {
return err
}
Expand All @@ -70,7 +70,7 @@ func newBuggifyCrashLoop(streams genericclioptions.IOStreams) *cobra.Command {
buggifyProcessGroupOptions{
containerName: containerName,
wait: wait,
clear: clear,
clear: clearFlag,
clean: clean,
},
processGroupSelectionOpts,
Expand Down
4 changes: 2 additions & 2 deletions kubectl-fdb/cmd/buggify_no_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newBuggifyNoSchedule(streams genericclioptions.IOStreams) *cobra.Command {
if err != nil {
return err
}
clear, err := cmd.Flags().GetBool("clear")
clearFlag, err := cmd.Flags().GetBool("clear")
if err != nil {
return err
}
Expand All @@ -64,7 +64,7 @@ func newBuggifyNoSchedule(streams genericclioptions.IOStreams) *cobra.Command {
return updateNoScheduleList(cmd, kubeClient,
buggifyProcessGroupOptions{
wait: wait,
clear: clear,
clear: clearFlag,
clean: clean,
}, processGroupSelectionOpts)
},
Expand Down

0 comments on commit 4ecb27c

Please sign in to comment.