Skip to content

Commit 3f0c189

Browse files
committed
linting: address slice-append issues found by gocritic
cli/command/trust/inspect.go:74:33: appendAssign: append result not assigned to the same slice (gocritic) signatureRows[idx].Signers = append(sig.Signers, releasedRoleName) ^ cli/command/task/print.go:92:7: appendAssign: append result not assigned to the same slice (gocritic) t := append(tasks[:0:0], tasks...) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent a2c9f3c commit 3f0c189

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

cli/command/task/print.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ func Print(ctx context.Context, dockerCli command.Cli, tasks []swarm.Task, resol
8989
// Task-names are not unique in cases where "tasks" contains previous/rotated tasks.
9090
func generateTaskNames(ctx context.Context, tasks []swarm.Task, resolver *idresolver.IDResolver) ([]swarm.Task, error) {
9191
// Use a copy of the tasks list, to not modify the original slice
92-
t := append(tasks[:0:0], tasks...)
92+
// see https://github.com/go101/go101/wiki/How-to-efficiently-clone-a-slice%3F
93+
t := append(tasks[:0:0], tasks...) //nolint:gocritic // ignore appendAssign: append result not assigned to the same slice
9394

9495
for i, task := range t {
9596
serviceName, err := resolver.Resolve(ctx, swarm.Service{}, task.ServiceID)

cli/command/trust/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func getRepoTrustInfo(cli command.Cli, remote string) ([]byte, error) {
7171
// process the signatures to include repo admin if signed by the base targets role
7272
for idx, sig := range signatureRows {
7373
if len(sig.Signers) == 0 {
74-
signatureRows[idx].Signers = append(sig.Signers, releasedRoleName)
74+
signatureRows[idx].Signers = []string{releasedRoleName}
7575
}
7676
}
7777

0 commit comments

Comments
 (0)