Skip to content

Commit 8172b27

Browse files
committed
refactor: enable linter ST1008 'function's error value should be its last return value'
1 parent 48cddd3 commit 8172b27

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ linters:
3636
- '-ST1003' # disable rule 'Poorly chosen identifier'
3737
- '-ST1005' # disable rule 'Incorrectly formatted error string'
3838
- '-ST1006' # disable rule 'Poorly chosen receiver name'
39-
- '-ST1008' # disable rule 'Function’s error value should be its last return value'
4039
- '-ST1023' # disable rule 'Redundant type in variable declaration'
4140
- '-QF1001' # disable rule 'Apply De Morgan’s law'
4241
- '-QF1012' # disable rule 'Use fmt.Fprintf instead of x.Write(fmt.Sprintf(...))'

cmd/root_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,15 @@ func Test_Aliases(t *testing.T) {
237237
}
238238
for name, tt := range tests {
239239
t.Run(name, func(t *testing.T) {
240-
err, output := testExecCmd(ctx, strings.Fields(tt.args))
240+
output, err := testExecCmd(ctx, strings.Fields(tt.args))
241241
require.NoError(t, err)
242242
require.Contains(t, output, tt.expected)
243243
})
244244
}
245245
}
246246

247247
// testExecCmd will execute the root cobra command with args and return the output
248-
func testExecCmd(ctx context.Context, args []string) (error, string) {
248+
func testExecCmd(ctx context.Context, args []string) (string, error) {
249249
// Get command
250250
cmd, clients := Init(ctx)
251251

@@ -258,7 +258,7 @@ func testExecCmd(ctx context.Context, args []string) (error, string) {
258258
cmd.SetArgs(args)
259259
err := cmd.ExecuteContext(ctx)
260260
if err != nil {
261-
return err, ""
261+
return "", err
262262
}
263-
return nil, clientsMock.GetCombinedOutput()
263+
return clientsMock.GetCombinedOutput(), nil
264264
}

0 commit comments

Comments
 (0)