Skip to content

Commit

Permalink
[chore] Fix linter errors
Browse files Browse the repository at this point in the history
These are new violations due to updated linter and Go versions.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz committed Nov 15, 2024
1 parent ae43ecd commit 7ee4d91
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion hibp.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (s *hibp) precomputeHashes(ctx context.Context) (map[string]string, []strin
// go templates to extract and compare data from the body
sec, err := s.gp.Get(ctx, secret, "latest")
if err != nil {
fmt.Printf("\n" + color.YellowString("Failed to retrieve secret '%s': %s\n", secret, err))
fmt.Printf("%s", "\n"+color.YellowString("Failed to retrieve secret '%s': %s\n", secret, err))

continue
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/hibp/api/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func TestLookup(t *testing.T) { //nolint:paralleltest
return
}
if strings.TrimPrefix(r.URL.String(), "/range/") == matchSum[:5] {
fmt.Fprintf(w, matchSum[5:10]+":1\r\n") // invalid
fmt.Fprintf(w, matchSum[5:39]+":3234879\r\n") // invalid
fmt.Fprintf(w, matchSum[5:]+":\r\n") // invalid
fmt.Fprintf(w, matchSum[5:]+"\r\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:10]+":1\r\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:39]+":3234879\r\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:]+":\r\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:]+"\r\n") // invalid
fmt.Fprintf(w, "%s:%d\r\n", matchSum[5:], matchCount) // valid

return
Expand Down Expand Up @@ -79,10 +79,10 @@ func TestLookupCR(t *testing.T) { //nolint:paralleltest
return
}
if strings.TrimPrefix(r.URL.String(), "/range/") == matchSum[:5] {
fmt.Fprintf(w, matchSum[5:10]+":1\n") // invalid
fmt.Fprintf(w, matchSum[5:39]+":3234879\n") // invalid
fmt.Fprintf(w, matchSum[5:]+":\n") // invalid
fmt.Fprintf(w, matchSum[5:]+"\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:10]+":1\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:39]+":3234879\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:]+":\n") // invalid
fmt.Fprintf(w, "%s", matchSum[5:]+"\n") // invalid
fmt.Fprintf(w, "%s:%d\n", matchSum[5:], matchCount) // valid

return
Expand Down
10 changes: 5 additions & 5 deletions pkg/hibp/api/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ func Download(ctx context.Context, path string, keep bool) error {

fmt.Printf("Downloading hashes to %s ...", dir)

max := 1024 * 1024
bar := termio.NewProgressBar(int64(max))
maxVal := 1024 * 1024
bar := termio.NewProgressBar(int64(maxVal))
bar.Hidden = ctxutil.IsHidden(ctx)

sem := make(chan struct{}, runtime.NumCPU()*4)
wg := &sync.WaitGroup{}
for i := range max {
for i := range maxVal {
wg.Add(1)
go func() {
sem <- struct{}{}
Expand All @@ -56,7 +56,7 @@ func Download(ctx context.Context, path string, keep bool) error {
<-sem
wg.Done()
}()
if err := downloadChunk(ctx, i, dir, keep); err != nil {
if err := downloadChunk(i, dir, keep); err != nil {
fmt.Printf("Chunk %d failed: %s", i, err)
}
}()
Expand Down Expand Up @@ -139,7 +139,7 @@ func copyChunk(w io.Writer, fn string) error {
return err
}

func downloadChunk(ctx context.Context, chunk int, dir string, keep bool) error {
func downloadChunk(chunk int, dir string, keep bool) error {
hex := fmt.Sprintf("%X", chunk)
prefix := strings.Repeat("0", 5-len(hex)) + hex

Expand Down
8 changes: 4 additions & 4 deletions pkg/hibp/dump/merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func (s *Scanner) Merge(ctx context.Context, outfile string) error { //nolint:cy
}
}
if lv[:40] == rv[:40] {
max := lv[41:]
if rv[41:] > max {
max = rv[41:]
maxVal := lv[41:]
if rv[41:] > maxVal {
maxVal = rv[41:]
}
fmt.Fprintf(gzw, "%s:%s\n", lv[:40], max)
fmt.Fprintf(gzw, "%s:%s\n", lv[:40], maxVal)

continue
}
Expand Down

0 comments on commit 7ee4d91

Please sign in to comment.