Skip to content

Commit 6776b31

Browse files
judehungFelixTing
authored andcommitted
fix: Fix two SonarQube scan failures
1. go:S117 2. go:S1186 Signed-off-by: Jude Hung <[email protected]>
1 parent c5a4b8e commit 6776b31

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

internal/pkg/infrastructure/postgres/device.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,21 +255,21 @@ func (c *Client) DeviceTree(parent string, levels int, offset int, limit int, la
255255
} else {
256256
maxLevels = levels
257257
}
258-
all_devices, err := deviceSubTree(context.Background(), c.ConnPool, parent, maxLevels, labels)
258+
allDevices, err := deviceSubTree(context.Background(), c.ConnPool, parent, maxLevels, labels)
259259
if err != nil {
260260
return 0, emptyList, err
261261
}
262262
if offset < 0 {
263263
offset = 0
264264
}
265-
if offset >= len(all_devices) {
266-
return uint32(len(all_devices)), emptyList, nil
265+
if offset >= len(allDevices) {
266+
return uint32(len(allDevices)), emptyList, nil
267267
}
268-
numToReturn := len(all_devices) - offset
268+
numToReturn := len(allDevices) - offset
269269
if limit > 0 && limit < numToReturn {
270270
numToReturn = limit
271271
}
272-
return uint32(len(all_devices)), all_devices[offset : offset+numToReturn], nil
272+
return uint32(len(allDevices)), allDevices[offset : offset+numToReturn], nil
273273
}
274274

275275
func deviceNameExists(ctx context.Context, connPool *pgxpool.Pool, name string) (bool, errors.EdgeX) {

internal/pkg/infrastructure/redis/device.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,19 +345,19 @@ func deviceTree(conn redis.Conn, parent string, levels int, offset int, limit in
345345
} else {
346346
maxLevels = levels
347347
}
348-
all_devices, err := deviceSubTree(conn, parent, maxLevels, labels)
348+
allDevices, err := deviceSubTree(conn, parent, maxLevels, labels)
349349
if err != nil {
350350
return 0, emptyList, err
351351
}
352352
if offset < 0 {
353353
offset = 0
354354
}
355-
if offset >= len(all_devices) {
356-
return uint32(len(all_devices)), emptyList, nil
355+
if offset >= len(allDevices) {
356+
return uint32(len(allDevices)), emptyList, nil
357357
}
358-
numToReturn := len(all_devices) - offset
358+
numToReturn := len(allDevices) - offset
359359
if limit > 0 && limit < numToReturn {
360360
numToReturn = limit
361361
}
362-
return uint32(len(all_devices)), all_devices[offset : offset+numToReturn], nil
362+
return uint32(len(allDevices)), allDevices[offset : offset+numToReturn], nil
363363
}

internal/security/config/command/proxy/shared/proxyuser.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ func NewProxyUserCommon(
9797
// LoadServiceToken loads a token from SecretStore.TokenFile (secrets-token.json)
9898
func (vb *ProxyUserCommon) LoadServiceToken() (string, func(), error) {
9999

100-
// This is not a root token; don't need to revoke when we're done with it
101-
revokeFunc := func() {}
100+
revokeFunc := func() {
101+
// This is not a root token; don't need to revoke when we're done with it
102+
}
102103

103104
tokenLoader := authtokenloader.NewAuthTokenLoader(vb.fileOpener)
104105

0 commit comments

Comments
 (0)