Skip to content

Commit b8f0ff8

Browse files
authored
[chore]: linting (#2840)
Signed-off-by: Fernandez Ludovic <[email protected]>
1 parent 57f19d2 commit b8f0ff8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+56
-110
lines changed

.golangci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
run:
2-
skip-dirs:
3-
- helpers/
4-
go: 1.22
5-
deadline: 5m
2+
timeout: 5m
63

74
linters-settings:
85
gocyclo:
@@ -80,6 +77,14 @@ linters:
8077
- wsl
8178

8279
issues:
83-
exclude-use-default: false # disable filtering of defaults for better zero-issue policy
84-
max-per-linter: 0 # disable limit; report all issues of a linter
80+
max-issues-per-linter: 0 # disable limit; report all issues of a linter
8581
max-same-issues: 0 # disable limit; report all issues of the same issue
82+
exclude-use-default: false # disable filtering of defaults for better zero-issue policy
83+
exclude-dirs:
84+
- helpers/
85+
86+
output:
87+
sort-results: true
88+
sort-order:
89+
- linter
90+
- file

internal/action/clihelper_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ func TestParseArgs(t *testing.T) {
6565
kvOut: map[string]string{"baz": "bam"},
6666
},
6767
} {
68-
tc := tc
69-
7068
t.Run(tc.name, func(t *testing.T) {
7169
if tc.argOut == nil {
7270
tc.argOut = argList{}

internal/action/commands_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func TestCommands(t *testing.T) {
4848
ctx = act.cfg.WithConfig(ctx) //nolint:ineffassign
4949

5050
for _, cmd := range act.GetCommands() {
51-
cmd := cmd
5251
t.Run(cmd.Name, func(t *testing.T) {
5352
testCommand(t, cmd)
5453
})

internal/action/generate_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ func TestKeyAndLength(t *testing.T) {
244244
length: "",
245245
},
246246
} {
247-
tc := tc
248-
249247
t.Run(fmt.Sprintf("%v", tc.in), func(t *testing.T) {
250248
app := cli.NewApp()
251249
fs := flag.NewFlagSet("default", flag.ContinueOnError)
@@ -272,7 +270,6 @@ func TestExtractEmails(t *testing.T) {
272270
273271
},
274272
} {
275-
tc := tc
276273
t.Run(fmt.Sprintf("%v", tc.in), func(t *testing.T) {
277274
assert.Equal(t, tc.out, extractEmails(tc.in))
278275
})
@@ -292,7 +289,6 @@ func TestExtractDomains(t *testing.T) {
292289
out: []string{"gmail.com", "live.com", "web.de"},
293290
},
294291
} {
295-
tc := tc
296292
t.Run(fmt.Sprintf("%v", tc.in), func(t *testing.T) {
297293
assert.Equal(t, tc.out, extractDomains(tc.in))
298294
})
@@ -312,7 +308,6 @@ func TestUniq(t *testing.T) {
312308
out: []string{"bar", "foo"},
313309
},
314310
} {
315-
tc := tc
316311
t.Run(fmt.Sprintf("%v", tc.in), func(t *testing.T) {
317312
assert.Equal(t, tc.out, uniq(tc.in))
318313
})
@@ -339,7 +334,6 @@ func TestFilterPrefix(t *testing.T) {
339334
out: []string{"foo/bar", "foo/baz"},
340335
},
341336
} {
342-
tc := tc
343337
t.Run(fmt.Sprintf("%v", tc.in), func(t *testing.T) {
344338
assert.Equal(t, tc.out, filterPrefix(tc.in, tc.prefix))
345339
})
@@ -372,7 +366,6 @@ func TestDefaultLengthFromEnv(t *testing.T) {
372366
{in: "abc", expected: config.DefaultPasswordLength, custom: false},
373367
{in: "-1", expected: config.DefaultPasswordLength, custom: false},
374368
} {
375-
tc := tc
376369
t.Setenv(pwLengthEnvName, tc.in)
377370
actual, isCustom := config.DefaultPasswordLengthFromEnv(ctx)
378371
assert.Equal(t, tc.expected, actual)

internal/action/init_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ func TestInitParseContext(t *testing.T) {
9898
},
9999
},
100100
} {
101-
tc := tc
102-
103101
t.Run(tc.name, func(t *testing.T) {
104102
c := gptest.CliCtxWithFlags(config.NewContextInMemory(), t, tc.flags)
105103
require.NoError(t, tc.check(initParseContext(c.Context, c)), tc.name)

internal/action/pwgen/pwgen.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func xkcdGen(c *cli.Context, length, num int) error {
7171
numbers = c.Bool("xkcdnumbers")
7272
}
7373

74-
for i := 0; i < num; i++ {
74+
for range num {
7575
s, err := xkcdgen.RandomLengthDelim(length, sep, lang, capitalize, numbers)
7676
if err != nil {
7777
return err
@@ -109,8 +109,8 @@ func pwGen(c *cli.Context, pwLen, pwNum int) error {
109109
charset += pwgen.Syms
110110
}
111111

112-
for i := 0; i < pwNum; i++ {
113-
for j := 0; j < perLine; j++ {
112+
for range pwNum {
113+
for range perLine {
114114
ctx := out.WithNewline(ctx, false)
115115
out.Print(ctx, pwgen.GeneratePasswordCharset(pwLen, charset))
116116
out.Print(ctx, " ")

internal/action/recipients.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,13 @@ func (s *Action) RecipientsAdd(c *cli.Context) error {
141141
continue
142142
}
143143

144-
recp := r
145144
debug.Log("found recipients for %q: %+v", r, keys)
146145

147-
if !termio.AskForConfirmation(ctx, fmt.Sprintf("Do you want to add %q (key %q) as a recipient to the store %q?", crypto.FormatKey(ctx, recp, ""), recp, store)) {
146+
if !termio.AskForConfirmation(ctx, fmt.Sprintf("Do you want to add %q (key %q) as a recipient to the store %q?", crypto.FormatKey(ctx, r, ""), r, store)) {
148147
continue
149148
}
150149

151-
if err := s.Store.AddRecipient(ctx, store, recp); err != nil {
150+
if err := s.Store.AddRecipient(ctx, store, r); err != nil {
152151
return exit.Error(exit.Recipients, err, "failed to add recipient %q: %s", r, err)
153152
}
154153
added++
@@ -201,7 +200,7 @@ func (s *Action) RecipientsRemove(c *cli.Context) error {
201200
}
202201
}
203202

204-
// if we a literal recipient (e.g. ID) is given just remove that w/o any kind of lookups.
203+
// if a literal recipient (e.g. ID) is given just remove that w/o any kind of lookups.
205204
if set.Contains(knownRecipients, r) {
206205
debug.Log("Removing %q from %q (direct)", r, store)
207206
if err := s.Store.RemoveRecipient(ctx, store, r); err != nil {
@@ -213,7 +212,7 @@ func (s *Action) RecipientsRemove(c *cli.Context) error {
213212
continue
214213
}
215214

216-
// look up the full key ID of the given recipient (could be email or any kinf of short ID)
215+
// look up the full key ID of the given recipient (could be email or any kind of short ID)
217216
keys, err := crypto.FindRecipients(ctx, r)
218217
if err != nil {
219218
out.Printf(ctx, "WARNING: Failed to list public key %q: %s", r, err)
@@ -235,7 +234,7 @@ func (s *Action) RecipientsRemove(c *cli.Context) error {
235234
continue
236235
}
237236

238-
recp := r
237+
recp := r //nolint:copyloopvar
239238
if len(keys) > 0 {
240239
if nr := crypto.Fingerprint(ctx, keys[0]); nr != "" {
241240
debug.Log("Fingerprint translated %q into %q", keys[0], nr)

internal/audit/audit.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (a *Auditor) Batch(ctx context.Context, secrets []string) (*Report, error)
149149
debug.Log("launching %d audit workers", maxJobs)
150150

151151
done := make(chan struct{}, maxJobs)
152-
for jobs := 0; jobs < maxJobs; jobs++ {
152+
for range maxJobs {
153153
go a.audit(ctx, pending, done)
154154
}
155155

@@ -166,7 +166,7 @@ func (a *Auditor) Batch(ctx context.Context, secrets []string) (*Report, error)
166166
bar.Inc()
167167
}
168168

169-
for i := 0; i < maxJobs; i++ {
169+
for range maxJobs {
170170
<-done
171171
}
172172
bar.Done()
@@ -228,8 +228,6 @@ func (a *Auditor) auditSecret(ctx context.Context, secret string) {
228228
// pass the secret to all validators.
229229
var wg sync.WaitGroup
230230
for _, v := range a.v {
231-
v := v
232-
233231
wg.Add(1)
234232
go func() {
235233
defer wg.Done()

internal/backend/crypto/gpg/colons/parse_colons_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ func TestParseColonIdentity(t *testing.T) {
4141
email: "",
4242
},
4343
} {
44-
tc := tc
4544
t.Run(tc.in, func(t *testing.T) {
4645
t.Parallel()
4746

internal/backend/crypto/gpg/gpgconf/version_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ func TestSort(t *testing.T) {
3939
},
4040
},
4141
} {
42-
tc := tc
43-
4442
t.Run(tc.name, func(t *testing.T) {
4543
t.Parallel()
4644

0 commit comments

Comments
 (0)