Skip to content

Commit dd86389

Browse files
Address some linting issues (#390)
1 parent ad82a8e commit dd86389

File tree

11 files changed

+34
-227
lines changed

11 files changed

+34
-227
lines changed

hack/generate/generate.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"io/ioutil"
56
"log"
67
"os"
@@ -95,11 +96,14 @@ func mustWriteTemplates(jobs []templateJob) {
9596
if err != nil {
9697
log.Fatal(err)
9798
}
98-
tmpl.Execute(f, templateData{
99+
err = tmpl.Execute(f, templateData{
99100
NameTitle: nameTitle,
100101
NameLower: nameLower,
101102
NameUpper: nameUpper,
102103
})
104+
if err != nil {
105+
log.Fatal(fmt.Errorf("failed to execute template: %w", err))
106+
}
103107
}
104108
}
105109

pkg/common/filter_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ func testFilterWriteFile(filename string, content []byte) error {
163163
if err != nil {
164164
return err
165165
}
166-
f.Write(content)
166+
_, err = f.Write(content)
167+
if err != nil {
168+
return err
169+
}
167170
return f.Close()
168171
}

pkg/detectors/bitfinex/bitfinex.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package bitfinex
33
import (
44
"context"
55
"flag"
6+
"net/http"
67
"regexp"
78
"strings"
89

@@ -27,8 +28,7 @@ var (
2728
)
2829

2930
var (
30-
orderid = flag.String("id", "", "lookup trades for an order ID")
31-
api = flag.String("api", "https://api-pub.bitfinex.com/v2/", "v2 REST API URL")
31+
api = flag.String("api", "https://api-pub.bitfinex.com/v2/", "v2 REST API URL")
3232
)
3333

3434
// Keywords are used for efficiently pre-filtering chunks.
@@ -69,6 +69,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
6969
// thankfully official golang examples exist but you just need to dig their many repos https://github.com/bitfinexcom/bitfinex-api-go/blob/master/examples/v2/rest-orders/main.go
7070
key := apiKeyRes
7171
secret := apiSecretRes
72+
http.DefaultClient = client // filed https://github.com/bitfinexcom/bitfinex-api-go/issues/238 to improve this
7273
c := rest.NewClientWithURL(*api).Credentials(key, secret)
7374

7475
isValid := true // assume valid

pkg/detectors/bitfinex/bitfinex_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ func TestBitfinex_FromChunk(t *testing.T) {
5050
DetectorType: detectorspb.DetectorType_Bitfinex,
5151
Verified: true,
5252
},
53-
{
54-
DetectorType: detectorspb.DetectorType_Bitfinex,
55-
Verified: false,
56-
},
5753
},
5854
wantErr: false,
5955
},
@@ -70,10 +66,6 @@ func TestBitfinex_FromChunk(t *testing.T) {
7066
DetectorType: detectorspb.DetectorType_Bitfinex,
7167
Verified: false,
7268
},
73-
{
74-
DetectorType: detectorspb.DetectorType_Bitfinex,
75-
Verified: false,
76-
},
7769
},
7870
wantErr: false,
7971
},

pkg/detectors/buddyns/buddyns/buddyns.go

Lines changed: 0 additions & 75 deletions
This file was deleted.

pkg/detectors/buddyns/buddyns/buddyns_test.go

Lines changed: 0 additions & 113 deletions
This file was deleted.

pkg/detectors/elasticemail/elasticemail.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,3 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
9191
}
9292
return detectors.CleanResults(results), nil
9393
}
94-
func prettyPrint(i interface{}) string {
95-
s, _ := json.MarshalIndent(i, "", "\t")
96-
return string(s)
97-
}

pkg/detectors/generic/generic.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,22 @@ func hasReMatch(matchers []*regexp.Regexp, token string) bool {
118118
return false
119119
}
120120

121-
func hasDictWord(wordList []string, token string) bool {
122-
lower := strings.ToLower(token)
123-
for _, word := range wordList {
124-
if strings.Contains(lower, word) {
125-
return true
126-
}
127-
}
128-
return false
129-
}
130-
131-
func bytesToCleanWordList(data []byte) []string {
132-
words := []string{}
133-
for _, word := range strings.Split(string(data), "\n") {
134-
if strings.TrimSpace(word) != "" {
135-
words = append(words, strings.TrimSpace(strings.ToLower(word)))
136-
}
137-
}
138-
return words
139-
}
121+
// func hasDictWord(wordList []string, token string) bool {
122+
// lower := strings.ToLower(token)
123+
// for _, word := range wordList {
124+
// if strings.Contains(lower, word) {
125+
// return true
126+
// }
127+
// }
128+
// return false
129+
// }
130+
131+
// func bytesToCleanWordList(data []byte) []string {
132+
// words := []string{}
133+
// for _, word := range strings.Split(string(data), "\n") {
134+
// if strings.TrimSpace(word) != "" {
135+
// words = append(words, strings.TrimSpace(strings.ToLower(word)))
136+
// }
137+
// }
138+
// return words
139+
// }

pkg/detectors/privatekey/normalize.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"strings"
55
)
66

7-
const b64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
8-
97
func normalize(in string) string {
108
in = strings.ReplaceAll(in, `"`, "")
119
in = strings.ReplaceAll(in, `'`, "")

pkg/detectors/privatekey/privatekey.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type Scanner struct {
2323
var _ detectors.Detector = (*Scanner)(nil)
2424

2525
var (
26+
// TODO: add base64 encoded key support
2627
client = common.RetryableHttpClient()
2728
keyPat = regexp.MustCompile(`(?i)-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY\s*?-----[\s\S]*?----\s*?END[ A-Z0-9_-]*? PRIVATE KEY\s*?-----`)
2829
)

0 commit comments

Comments
 (0)