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

Upgrade golangci-lint version #6135

Closed
wants to merge 2 commits into from
Closed
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
156 changes: 82 additions & 74 deletions boilerplate/flyte/golang_support_tools/go.mod

Large diffs are not rendered by default.

368 changes: 202 additions & 166 deletions boilerplate/flyte/golang_support_tools/go.sum

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions boilerplate/flyte/golangci_file/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@ run:
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gas
- gci
- goconst
- goimports
- golint
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck

linters-settings:
gci:
Expand Down
3 changes: 3 additions & 0 deletions datacatalog/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ linters-settings:
- default
- prefix(github.com/flyteorg)
skip-generated: true
gosec:
excludes:
- G601 # disable the rule G601 since its not relevant in go 1.22+
goconst:
ignore-tests: true
issues:
Expand Down
3 changes: 3 additions & 0 deletions flyteadmin/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ linters-settings:
- default
- prefix(github.com/flyteorg)
skip-generated: true
gosec:
excludes:
- G601 # disable the rule G601 since its not relevant in go 1.22+
goconst:
ignore-tests: true
issues:
Expand Down
1 change: 0 additions & 1 deletion flyteadmin/pkg/async/schedule/aws/workflow_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ func generateExecutionName(launchPlan *admin.LaunchPlan, kickoffTime time.Time)
Name: launchPlan.GetId().GetName(),
})
randomSeed := kickoffTime.UnixNano() + int64(hashedIdentifier) // #nosec G115

return common.GetExecutionName(randomSeed)
}

Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewAlreadyInTerminalStateError(ctx context.Context, errorMsg string, curPha
statusErr, transformationErr := NewFlyteAdminError(codes.FailedPrecondition, errorMsg).WithDetails(reason)
if transformationErr != nil {
logger.Panicf(ctx, "Failed to wrap grpc status in type 'Error': %v", transformationErr)
return NewFlyteAdminErrorf(codes.FailedPrecondition, errorMsg) //nolint
return NewFlyteAdminErrorf(codes.FailedPrecondition, errorMsg) //nolint
}
return statusErr
}
Expand All @@ -106,7 +106,7 @@ func NewIncompatibleClusterError(ctx context.Context, errorMsg, curCluster strin
})
if transformationErr != nil {
logger.Panicf(ctx, "Failed to wrap grpc status in type 'Error': %v", transformationErr) //nolint
return NewFlyteAdminErrorf(codes.FailedPrecondition, errorMsg) //nolint
return NewFlyteAdminErrorf(codes.FailedPrecondition, errorMsg) //nolint
}
return statusErr
}
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/pkg/repositories/transformers/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func FromWorkflowModel(workflowModel models.Workflow) (admin.Workflow, error) {
if len(workflowModel.TypedInterface) > 0 {
err = proto.Unmarshal(workflowModel.TypedInterface, &workflowInterface)
if err != nil {
return admin.Workflow{}, errors.NewFlyteAdminErrorf(codes.Internal, fmt.Sprintf("failed to unmarshal workflow %v interface. Error message: %v", workflowModel.ID, err.Error())) //nolint
return admin.Workflow{}, errors.NewFlyteAdminErrorf(codes.Internal, fmt.Sprintf("failed to unmarshal workflow %v interface. Error message: %v", workflowModel.ID, err.Error())) //nolint
}
}

Expand Down
3 changes: 3 additions & 0 deletions flytecopilot/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ linters-settings:
- default
- prefix(github.com/flyteorg)
skip-generated: true
gosec:
excludes:
- G601 # disable the rule G601 since its not relevant in go 1.22+
goconst:
ignore-tests: true
5 changes: 5 additions & 0 deletions flytectl/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ linters:
- unparam
- unused
- protogetter

linters-settings:
gci:
skip-generated: true
gosec:
excludes:
- G601 # disable the rule G601 since its not relevant in go 1.22+
goconst:
ignore-tests: true

issues:
exclude:
- copylocks
3 changes: 3 additions & 0 deletions flyteplugins/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ linters-settings:
- default
- prefix(github.com/flyteorg)
skip-generated: true
gosec:
excludes:
- G601 # disable the rule G601 since its not relevant in go 1.22+
issues:
exclude:
- copylocks
7 changes: 4 additions & 3 deletions flyteplugins/go/tasks/plugins/array/k8s/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import (
"context"
"errors"

Check failure on line 5 in flyteplugins/go/tasks/plugins/array/k8s/management.go

View workflow job for this annotation

GitHub Actions / compile

"errors" imported and not used
"fmt"
"time"

idlCore "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/errors"
flyteErrors "github.com/flyteorg/flyte/flyteplugins/go/tasks/errors"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/logs"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"
Expand Down Expand Up @@ -131,7 +132,7 @@
if err != nil {
return currentState, externalResources, err
} else if taskTemplate == nil {
return currentState, externalResources, errors.Errorf(errors.BadTaskSpecification, "Required value not set, taskTemplate is nil")
return currentState, externalResources, flyteErrors.Errorf(flyteErrors.BadTaskSpecification, "Required value not set, taskTemplate is nil")
}

arrayJob, err := arrayCore.ToArrayJob(taskTemplate.GetCustom(), taskTemplate.GetTaskTypeVersion())
Expand Down Expand Up @@ -355,7 +356,7 @@
if err != nil {
return currentState, externalResources, err
} else if taskTemplate == nil {
return currentState, externalResources, errors.Errorf(errors.BadTaskSpecification, "Required value not set, taskTemplate is nil")
return currentState, externalResources, flyteErrors.Errorf(flyteErrors.BadTaskSpecification, "Required value not set, taskTemplate is nil")
}

messageCollector := errorcollector.NewErrorMessageCollector()
Expand Down
4 changes: 2 additions & 2 deletions flyteplugins/go/tasks/plugins/array/k8s/management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func TestCheckSubTasksState(t *testing.T) {

detailed := arrayCore.NewPhasesCompactArray(uint(subtaskCount)) // #nosec G115
for i := 0; i < subtaskCount; i++ {
detailed.SetItem(i, bitarray.Item(core.PhaseRetryableFailure)) // set all tasks to core.PhaseRetryableFailure
detailed.SetItem(i, bitarray.Item(core.PhaseRetryableFailure)) // #nosec G115 set all tasks to core.PhaseRetryableFailure
}

retryAttemptsArray, err := bitarray.NewCompactArray(uint(subtaskCount), bitarray.Item(1)) // #nosec G115
Expand Down Expand Up @@ -523,7 +523,7 @@ func TestCheckSubTasksState(t *testing.T) {
// #nosec G115
detailed := arrayCore.NewPhasesCompactArray(uint(subtaskCount))
for i := 0; i < subtaskCount; i++ {
detailed.SetItem(i, bitarray.Item(core.PhaseRunning)) // set all tasks to core.PhaseRunning
detailed.SetItem(i, bitarray.Item(core.PhaseRunning)) // #nosec G115 set all tasks to core.PhaseRunning
}

// #nosec G115
Expand Down
4 changes: 4 additions & 0 deletions flytepropeller/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ linters-settings:
- default
- prefix(github.com/flyteorg)
skip-generated: true
gosec:
excludes:
- G601 # disable the rule G601 since its not relevant in go 1.22+
goconst:
ignore-tests: true
issues:
exclude:
- copylocks

14 changes: 7 additions & 7 deletions flytepropeller/pkg/controller/nodes/array/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/config"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/executors"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/common"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/errors"
flyteErrors "github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/errors"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/handler"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/interfaces"
"github.com/flyteorg/flyte/flytepropeller/pkg/controller/nodes/task/k8s"
Expand Down Expand Up @@ -206,7 +206,7 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu
if err != nil {
errMsg := fmt.Sprintf("Failed to validate literal type for [%s] with err: %s", key, err)
return handler.DoTransition(handler.TransitionTypeEphemeral,
handler.PhaseInfoFailure(idlcore.ExecutionError_USER, errors.IDLNotFoundErr, errMsg, nil),
handler.PhaseInfoFailure(idlcore.ExecutionError_USER, flyteErrors.IDLNotFoundErr, errMsg, nil),
), nil
}
if variable.GetOffloadedMetadata() != nil {
Expand All @@ -215,7 +215,7 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu
err := common.ReadLargeLiteral(ctx, nCtx.DataStore(), variable)
if err != nil {
return handler.DoTransition(handler.TransitionTypeEphemeral,
handler.PhaseInfoFailure(idlcore.ExecutionError_SYSTEM, errors.RuntimeExecutionError, "couldn't read the offloaded literal", nil),
handler.PhaseInfoFailure(idlcore.ExecutionError_SYSTEM, flyteErrors.RuntimeExecutionError, "couldn't read the offloaded literal", nil),
), nil
}
}
Expand All @@ -226,7 +226,7 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu
size = collectionLength
} else if size != collectionLength {
return handler.DoTransition(handler.TransitionTypeEphemeral,
handler.PhaseInfoFailure(idlcore.ExecutionError_USER, errors.InvalidArrayLength,
handler.PhaseInfoFailure(idlcore.ExecutionError_USER, flyteErrors.InvalidArrayLength,
fmt.Sprintf("input arrays have different lengths: expecting '%d' found '%d'", size, collectionLength), nil),
), nil
}
Expand All @@ -235,7 +235,7 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu

if size == -1 {
return handler.DoTransition(handler.TransitionTypeEphemeral,
handler.PhaseInfoFailure(idlcore.ExecutionError_USER, errors.InvalidArrayLength, "no input array provided", nil),
handler.PhaseInfoFailure(idlcore.ExecutionError_USER, flyteErrors.InvalidArrayLength, "no input array provided", nil),
), nil
}

Expand Down Expand Up @@ -546,7 +546,7 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu
taskNode, err := nCtx.ExecutionContext().GetTask(taskID)
if err != nil {
return handler.DoTransition(handler.TransitionTypeEphemeral, handler.PhaseInfoFailure(idlcore.ExecutionError_SYSTEM,
errors.BadSpecificationError, fmt.Sprintf("failed to find ArrayNode subNode task with id: '%s'", taskID), nil)), nil
flyteErrors.BadSpecificationError, fmt.Sprintf("failed to find ArrayNode subNode task with id: '%s'", taskID), nil)), nil
}

if outputs := taskNode.CoreTask().GetInterface().GetOutputs(); outputs != nil {
Expand Down Expand Up @@ -617,7 +617,7 @@ func (a *arrayNodeHandler) Handle(ctx context.Context, nCtx interfaces.NodeExecu
},
)), nil
default:
return handler.UnknownTransition, errors.Errorf(errors.IllegalStateError, nCtx.NodeID(), "invalid ArrayNode phase %+v", arrayNodeState.Phase)
return handler.UnknownTransition, flyteErrors.Errorf(flyteErrors.IllegalStateError, nCtx.NodeID(), "invalid ArrayNode phase %+v", arrayNodeState.Phase)
}

// if there were changes to subNode status then the eventRecorder will require finalizing to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ func TestPluginManager_Handle_PluginState(t *testing.T) {
}

for _, tt := range tests {

t.Run(tt.name, func(t *testing.T) {
// mock TaskExecutionContext
tCtx := &pluginsCoreMock.TaskExecutionContext{}
Expand Down
1 change: 0 additions & 1 deletion flytestdlib/bitarray/bitset.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (s *BitSet) BlockCount() int {
// Returns the length of the BitSet.
func (s *BitSet) Cap() uint {
return uint(s.BlockCount()) * blockSize // #nosec G115

}

// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
Expand Down
2 changes: 0 additions & 2 deletions flytestdlib/bitarray/compact_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ func (a *CompactArray) SetItem(index int, value Item) {
for i := int(a.ItemSize - 1); i >= 0; i-- {
if x&value != 0 {
a.BitSet.Set(bitIndex + uint(i)) // #nosec G115

} else {
a.BitSet.Clear(bitIndex + uint(i)) // #nosec G115

}

x <<= 1
Expand Down
2 changes: 0 additions & 2 deletions flytestdlib/bitarray/compact_array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func BenchmarkCompactArray_SetItem(b *testing.B) {

b.ResetTimer()
arr, err := NewCompactArray(itemsCount, Item(b.N)) // #nosec G115

assert.NoError(b, err)

for i := 0; i < b.N; i++ {
Expand Down Expand Up @@ -140,7 +139,6 @@ func TestPanicOnOversizedValue(t *testing.T) {
assert.Panics(t, func() { itemArray.validateValue(4) })
for i := 0; i < 4; i++ {
assert.NotPanics(t, func() { itemArray.validateValue(Item(i)) }) // #nosec G115

}
}

Expand Down
7 changes: 4 additions & 3 deletions flytestdlib/storage/copy_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package storage

import (
"context"
"errors"
"fmt"
"io"
"math/rand"
"testing"

"github.com/stretchr/testify/assert"

"github.com/flyteorg/flyte/flytestdlib/errors"
flyteErrors "github.com/flyteorg/flyte/flytestdlib/errors"
"github.com/flyteorg/flyte/flytestdlib/ioutils"
)

Expand Down Expand Up @@ -98,11 +99,11 @@ func TestCopyRaw_CachingErrorHandling(t *testing.T) {
ReadRawCb: func(ctx context.Context, reference DataReference) (closer io.ReadCloser, e error) {
readerCalled = true
//nolint:govet,staticcheck
return ioutils.NewBytesReadCloser(bigD), errors.Wrapf(ErrFailedToWriteCache, fmt.Errorf(dummyErrorMsg), "Failed to Cache the metadata")
return ioutils.NewBytesReadCloser(bigD), flyteErrors.Wrapf(ErrFailedToWriteCache, fmt.Errorf(dummyErrorMsg), "Failed to Cache the metadata")
},
WriteRawCb: func(ctx context.Context, reference DataReference, size int64, opts Options, raw io.Reader) error {
writerCalled = true
return errors.Wrapf(ErrFailedToWriteCache, fmt.Errorf(dummyErrorMsg), "Failed to Cache the metadata") //nolint:govet,staticcheck
return flyteErrors.Wrapf(ErrFailedToWriteCache, fmt.Errorf(dummyErrorMsg), "Failed to Cache the metadata") //nolint:govet,staticcheck
},
}

Expand Down
1 change: 0 additions & 1 deletion flytestdlib/storage/stow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ const (

func (l locationID) String() string {
return strconv.Itoa(int(l)) // #nosec G115

}

func (s *StowStore) getLocation(id locationID) stow.Location {
Expand Down
Loading