Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sebrandon1 committed Nov 27, 2024
1 parent 45071b7 commit b784888
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ linters-settings:
checks:
- all
- ST1001
- "-SA1006"


linters:
enable:
Expand Down Expand Up @@ -122,7 +124,6 @@ linters:
- predeclared
- promlinter
- revive
- staticcheck
- stylecheck
- tenv
- thelper
Expand Down
4 changes: 2 additions & 2 deletions pkg/clusterlogging/clusterlogging.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,13 @@ func (builder *Builder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/hive/clusterimageset.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ func (builder *ClusterImageSetBuilder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/ibi/imageclusterinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ func (builder *ImageClusterInstallBuilder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/network/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ func (builder *OperatorBuilder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
4 changes: 1 addition & 3 deletions pkg/ocm/placementbinding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,11 @@ func TestPlacementBindingUpdate(t *testing.T) {
}

for _, testCase := range testCases {
testBuilder := buildValidPlacementBindingTestBuilder(buildTestClientWithPlacementBindingScheme())

// Create the builder rather than just adding it to the client so that the proper metadata is added and
// the update will not fail.
var err error

testBuilder = buildValidPlacementBindingTestBuilder(buildTestClientWithPlacementBindingScheme())
testBuilder := buildValidPlacementBindingTestBuilder(buildTestClientWithPlacementBindingScheme())
testBuilder, err = testBuilder.Create()
assert.Nil(t, err)

Expand Down
4 changes: 1 addition & 3 deletions pkg/ocm/placementrule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,11 @@ func TestPlacementRuleUpdate(t *testing.T) {
}

for _, testCase := range testCases {
testBuilder := buildValidPlacementRuleTestBuilder(buildTestClientWithPlacementRuleScheme())

// Create the builder rather than just adding it to the client so that the proper metadata is added and
// the update will not fail.
var err error

testBuilder = buildValidPlacementRuleTestBuilder(buildTestClientWithPlacementRuleScheme())
testBuilder := buildValidPlacementRuleTestBuilder(buildTestClientWithPlacementRuleScheme())
testBuilder, err = testBuilder.Create()
assert.Nil(t, err)

Expand Down
4 changes: 1 addition & 3 deletions pkg/ocm/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,9 @@ func TestPolicyUpdate(t *testing.T) {
}

for _, testCase := range testCases {
testBuilder := buildValidPolicyTestBuilder(buildTestClientWithPolicyScheme())

var err error

testBuilder = buildValidPolicyTestBuilder(buildTestClientWithPolicyScheme())
testBuilder := buildValidPolicyTestBuilder(buildTestClientWithPolicyScheme())
testBuilder, err = testBuilder.Create()
assert.Nil(t, err)

Expand Down
1 change: 1 addition & 0 deletions pkg/ocm/policyset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func TestPolicySetUpdate(t *testing.T) {

for _, testCase := range testCases {
var err error

testBuilder := buildValidPolicySetTestBuilder(buildTestClientWithPolicySetScheme())
testBuilder, err = testBuilder.Create()
assert.Nil(t, err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/olm/catalogsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ func (builder *CatalogSourceBuilder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
2 changes: 0 additions & 2 deletions pkg/schemes/argocd/argocdtypes/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,6 @@ type ApplicationDestination struct {
// Name is an alternate way of specifying the target cluster by its symbolic name. This must be set if Server is not set.
Name string `json:"name,omitempty" protobuf:"bytes,3,opt,name=name"`

// nolint:govet
isServerInferred bool `json:"-"`
}

Expand Down Expand Up @@ -1080,7 +1079,6 @@ type SyncOperationResource struct {
Kind string `json:"kind" protobuf:"bytes,2,opt,name=kind"`
Name string `json:"name" protobuf:"bytes,3,opt,name=name"`
Namespace string `json:"namespace,omitempty" protobuf:"bytes,4,opt,name=namespace"`
// nolint:govet
Exclude bool `json:"-"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/servicemesh/controlplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,13 @@ func (builder *ControlPlaneBuilder) validate() (bool, error) {
if builder.Definition == nil {
glog.V(100).Infof("The %s is undefined", resourceCRD)

builder.errorMsg = msg.UndefinedCrdObjectErrString(resourceCRD)
return false, fmt.Errorf(msg.UndefinedCrdObjectErrString(resourceCRD))
}

if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down
10 changes: 3 additions & 7 deletions pkg/sriov/networknodestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,13 @@ func (builder *NetworkNodeStateBuilder) findInterfaceByName(sriovInterfaceName s
if err := builder.Discover(); err != nil {
glog.V(100).Infof("Error to discover sriov network node state for node %s", builder.nodeName)

builder.errorMsg = "failed to discover sriov network node state"
return nil, fmt.Errorf("error to discover sriov network node state for node %s", builder.nodeName)
}

if sriovInterfaceName == "" {
glog.V(100).Infof("The sriovInterface can not be empty string")

builder.errorMsg = "the sriovInterface is an empty sting"
}

if builder.errorMsg != "" {
return nil, fmt.Errorf(builder.errorMsg)
return nil, fmt.Errorf("sriovInterfaceName cannot be empty")
}

for _, interf := range builder.Objects.Status.Interfaces {
Expand All @@ -261,7 +257,7 @@ func (builder *NetworkNodeStateBuilder) validate() (bool, error) {
if builder.apiClient == nil {
glog.V(100).Infof("The %s builder apiclient is nil", resourceCRD)

builder.errorMsg = fmt.Sprintf("%s builder cannot have nil apiClient", resourceCRD)
return false, fmt.Errorf("%s builder cannot have nil apiClient", resourceCRD)
}

if builder.errorMsg != "" {
Expand Down

0 comments on commit b784888

Please sign in to comment.