Skip to content

Commit 82d1dbf

Browse files
authored
chore: upgrade golangci-lint (v2.1.6 => v2.5.0) (#337)
- Updated golangci-lint tool dependency to latest (v2.5.0) - Fixed code issues to resolve linter warnings --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 1a5d544 commit 82d1dbf

29 files changed

Lines changed: 317 additions & 94 deletions

File tree

.golangci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: "2"
22

33
linters:
44
enable:
5+
- arangolint
56
- asasalint
67
- asciicheck
78
- bidichk
@@ -16,6 +17,8 @@ linters:
1617
- dupl
1718
- dupword
1819
- durationcheck
20+
- embeddedstructfieldcheck
21+
- errcheck
1922
- errchkjson
2023
- errname
2124
- errorlint
@@ -24,6 +27,7 @@ linters:
2427
- fatcontext
2528
- forbidigo
2629
- forcetypeassert
30+
- funcorder
2731
- funlen
2832
- ginkgolinter
2933
- gocheckcompilerdirectives
@@ -34,6 +38,7 @@ linters:
3438
- goconst
3539
- gocritic
3640
- gocyclo
41+
- godoclint
3742
- godot
3843
- godox
3944
- goheader
@@ -42,12 +47,15 @@ linters:
4247
- goprintffuncname
4348
- gosec
4449
- gosmopolitan
50+
- govet
4551
- grouper
4652
- iface
4753
- importas
4854
- inamedparam
55+
- ineffassign
4956
- interfacebloat
5057
- intrange
58+
- iotamixing
5159
- lll
5260
- loggercheck
5361
- maintidx
@@ -63,6 +71,7 @@ linters:
6371
- nilnil
6472
- nlreturn
6573
- noctx
74+
- noinlineerr
6675
- nolintlint
6776
- nosprintfhostport
6877
- perfsprint
@@ -87,20 +96,26 @@ linters:
8796
- tparallel
8897
- unconvert
8998
- unparam
99+
- unqueryvet
100+
- unused
90101
- usestdlibvars
91102
- usetesting
92103
- varnamelen
93104
- wastedassign
94105
- whitespace
95106
- wrapcheck
96-
- wsl
107+
- wsl_v5
97108
- zerologlint
98109

99110
disable:
100111
- depguard # We will need to configure the allowed dependencies before enabling this
112+
- embeddedstructfieldcheck # Would require extensive struct reorganization
101113
- err113 # We're okay with dynamic errors for most cases; no way to only disable that check.
102114
- exhaustruct # We don't require explicitly initializing each field of a struct at construction time.
115+
- funcorder # Would require extensive code reorganization
116+
- godoclint # Would require updating all function documentation comments
103117
- ireturn # We are philosophically opposed to banning interface returns.
118+
- noinlineerr # We prefer inline error handling for readability
104119
- nonamedreturns # We *intentionally* like named returns.
105120
- paralleltest # We're not going to add t.Parallel() to every test for now.
106121

internal/app/azldev/app.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ func (a *App) handlePostInitCallbacks(env *Env) error {
392392
return nil
393393
}
394394

395-
if err := a.callPostInitCallbacks(env); err != nil {
395+
err := a.callPostInitCallbacks(env)
396+
if err != nil {
396397
return fmt.Errorf("error during post-config initialization: %w", err)
397398
}
398399

@@ -593,7 +594,8 @@ func (a *App) dispatchToCommand(env *Env, args []string) int {
593594
a.cmd.SetArgs(args)
594595
a.applyStylesToCommand()
595596

596-
if err := a.cmd.ExecuteContext(env); err != nil {
597+
err := a.cmd.ExecuteContext(env)
598+
if err != nil {
597599
slog.Error("Error: " + err.Error())
598600

599601
return 1

internal/app/azldev/cmds/component/buildtasks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func (d *FileArtifact) Ref() artifacts.Ref {
3636

3737
type sourcesTask struct {
3838
orchestration.BaseTask
39+
3940
component components.Component
4041
componentBuilder componentbuilder.ComponentBuilder
4142
services orchestration.TaskServicer
@@ -132,6 +133,7 @@ func (b *sourcesTaskBuilder) SetTaskServicer(services orchestration.TaskServicer
132133

133134
type binaryPackageTask struct {
134135
orchestration.BaseTask
136+
135137
componentBuilder componentbuilder.ComponentBuilder
136138
component components.Component
137139
runChecks bool

internal/app/azldev/cmds/component/buildtasks_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func setupTestComponentBuilder(t *testing.T) *componentbuilder.MockComponentBuil
9797

9898
func TestFileArtifact(t *testing.T) {
9999
const dummyFilePath = "/path/to/file.rpm"
100+
100101
artifact := &FileArtifact{Path: dummyFilePath}
101102

102103
t.Run("String contains file path", func(t *testing.T) {

internal/app/azldev/core/mcp/mcpserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func addToolForCmd(env *azldev.Env, srv *server.MCPServer, leaf *cobra.Command)
7676
}
7777

7878
var toolOptions []mcp.ToolOption
79+
7980
toolOptions = append(toolOptions, mcp.WithDescription(toolDesc))
8081

8182
flags := getAllFlagDefs(leaf)

internal/orchestration/artifacts/artifactref_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestBasicRefImplementation(t *testing.T) {
4646
// ExtendedRef embeds BasicRef and adds extra functionality.
4747
type ExtendedRef struct {
4848
artifacts.BasicRef
49+
4950
Version string
5051
}
5152

internal/orchestration/artifacts/artifacts_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func TestPromisedArtifactResolveAndAwait(t *testing.T) {
103103
))
104104

105105
done := make(chan struct{})
106+
106107
go func() {
107108
time.Sleep(100 * time.Millisecond)
108109
assert.NoError(t, promise.Resolve(artifact))
@@ -203,14 +204,14 @@ func TestPromisedArtifactConcurrentAccess(t *testing.T) {
203204
))
204205

205206
const numReaders = 20
207+
206208
results := make(chan artifacts.Artifact, numReaders)
207209
errors := make(chan error, numReaders)
208210

209211
// Start multiple readers
210212
for range numReaders {
211213
go func() {
212214
result, err := promise.Await(t.Context())
213-
214215
if err != nil {
215216
errors <- err
216217
} else {
@@ -285,6 +286,7 @@ func TestPromisedArtifactConcurrentAccess(t *testing.T) {
285286

286287
// Wait for all tasks to complete
287288
done := make(chan struct{})
289+
288290
go func() {
289291
waitGroup.Wait()
290292
close(done)
@@ -382,6 +384,7 @@ func TestPromisedArtifactConcurrentAccess(t *testing.T) {
382384
// Resolver goroutine
383385
go func() {
384386
defer waitGroup.Done()
387+
385388
assert.NoError(t, promise.Resolve(artifact))
386389
}()
387390

internal/orchestration/orchestration/tasks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func NewTaskID[T any](taskID string) (TaskID, error) {
3737
}
3838

3939
var zero T
40+
4041
taskType := reflect.TypeOf(zero).Name()
4142

4243
if taskType == "" {

internal/orchestration/orchestrator/orchestrator.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ func (o *Orchestrator) AssignTaskServices(taskBuilder orchestration.TaskBuilder)
111111
return nil
112112
}
113113

114-
if cleanupErr := o.cleanupTaskRuntimeUnsafe(taskID); cleanupErr != nil {
114+
cleanupErr := o.cleanupTaskRuntimeUnsafe(taskID)
115+
if cleanupErr != nil {
115116
return fmt.Errorf("failed to cleanup task runtime for task %#q: %w", taskID, cleanupErr)
116117
}
117118

@@ -142,7 +143,8 @@ func (o *Orchestrator) cleanupTaskRuntimeUnsafe(task orchestration.TaskID) error
142143
if runtime, exists := o.taskSet[task]; exists {
143144
delete(o.taskSet, task)
144145

145-
if err := runtime.Cleanup(); err != nil {
146+
err := runtime.Cleanup()
147+
if err != nil {
146148
return fmt.Errorf("failed to cleanup task runtime for task %#q: %w", task, err)
147149
}
148150
}
@@ -168,7 +170,8 @@ func (o *Orchestrator) Cleanup() (err error) {
168170
for task, runtimes := range o.taskSet {
169171
slog.Warn("Orphaned task runtime found during orchestrator cleanup", "taskID", task.ID())
170172

171-
if cleanupErr := runtimes.Cleanup(); cleanupErr != nil {
173+
cleanupErr := runtimes.Cleanup()
174+
if cleanupErr != nil {
172175
err = errors.Join(
173176
err,
174177
fmt.Errorf("failed to cleanup task %#q runtime during orchestrator cleanup: %w", task.ID(), cleanupErr),

internal/orchestration/orchestrator/orchestrator_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ func TestOrchestrator_RunTask_ContextCancellation(t *testing.T) {
370370

371371
// Run task in goroutine
372372
errChan := make(chan error, 1)
373+
373374
go func() {
374375
_, err := orch.RunTask(ctx, task)
375376
errChan <- err

0 commit comments

Comments
 (0)