Skip to content

Commit 0848143

Browse files
author
Paul Schwabauer
authored
Update lint (gocsaf#626)
* Update linter * Format * Fix lint
1 parent 5709b14 commit 0848143

File tree

7 files changed

+16
-19
lines changed

7 files changed

+16
-19
lines changed

.github/workflows/go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v4
1919
with:
20-
go-version: 'stable'
20+
go-version: "stable"
2121

2222
- name: Build
2323
run: go build -v ./cmd/...
@@ -31,10 +31,10 @@ jobs:
3131
gofmt-flags: "-l -d"
3232

3333
- name: golint
34-
uses: Jerome1337/golint-action@v1.0.2
34+
uses: Jerome1337/golint-action@v1.0.3
3535

3636
- name: Revive Action
37-
uses: morphy2k/revive-action@v2.5.1
37+
uses: morphy2k/revive-action@v2.7.4
3838

3939
- name: Tests
4040
run: go test -v ./...

cmd/csaf_aggregator/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ func Test_downloadJSON(t *testing.T) {
4949
test := testToRun
5050
t.Run(test.name, func(tt *testing.T) {
5151
tt.Parallel()
52-
found := func(r io.Reader) error {
52+
found := func(_ io.Reader) error {
5353
return nil
5454
}
55-
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
55+
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
5656
w.Header().Add("Content-Type", test.contentType)
5757
w.WriteHeader(test.statusCode)
5858
}))

cmd/csaf_downloader/downloader_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ import (
2424
func checkIfFileExists(path string, t *testing.T) bool {
2525
if _, err := os.Stat(path); err == nil {
2626
return true
27-
} else if errors.Is(err, os.ErrNotExist) {
28-
return false
29-
} else {
27+
} else if !errors.Is(err, os.ErrNotExist) {
3028
t.Fatalf("Failed to check if file exists: %v", err)
31-
return false
3229
}
30+
return false
3331
}
3432

3533
func TestShaMarking(t *testing.T) {

cmd/csaf_downloader/forwarder.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ func (f *forwarder) storeFailed(filename, doc, sha256, sha512 string) {
224224

225225
// limitedString reads max bytes from reader and returns it as a string.
226226
// Longer strings are indicated by "..." as a suffix.
227-
func limitedString(r io.Reader, max int) (string, error) {
227+
func limitedString(r io.Reader, maxLength int) (string, error) {
228228
var msg strings.Builder
229-
if _, err := io.Copy(&msg, io.LimitReader(r, int64(max))); err != nil {
229+
if _, err := io.Copy(&msg, io.LimitReader(r, int64(maxLength))); err != nil {
230230
return "", err
231231
}
232-
if msg.Len() >= max {
232+
if msg.Len() >= maxLength {
233233
msg.WriteString("...")
234234
}
235235
return msg.String(), nil

cmd/csaf_provider/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848

4949
cfg, err := loadConfig()
5050
if err != nil {
51-
cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
51+
cgi.Serve(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) {
5252
http.Error(rw, "Something went wrong. Check server logs for more details",
5353
http.StatusInternalServerError)
5454
}))

internal/options/options_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func TestParse(t *testing.T) {
3737
},
3838
Usage: "[OPTIONS] domain...",
3939
HasVersion: func(cfg *config) bool { return cfg.Version },
40-
SetDefaults: func(cfg *config) {
40+
SetDefaults: func(_ *config) {
4141
},
4242
// Re-establish default values if not set.
43-
EnsureDefaults: func(cfg *config) {
43+
EnsureDefaults: func(_ *config) {
4444
},
4545
}
4646

@@ -157,7 +157,6 @@ func TestErrorCheck(t *testing.T) {
157157
return
158158
}
159159
t.Fatalf("process ran with err %v, want exit status 1", err)
160-
161160
}
162161

163162
// TestSecondPassCommandlineParsing checks if the second pass
@@ -168,7 +167,7 @@ func TestSecondPassCommandlineParsing(t *testing.T) {
168167

169168
os.Args = []string{"cmd"}
170169
p := Parser[config]{
171-
ConfigLocation: func(cfg *config) string {
170+
ConfigLocation: func(_ *config) string {
172171
// This is a bit stupid.
173172
os.Args = []string{"cmd", "--invalid"}
174173
return "data/empty.toml"
@@ -188,7 +187,7 @@ func TestSecondPassCommandlineHelp(t *testing.T) {
188187

189188
os.Args = []string{"cmd"}
190189
p := Parser[config]{
191-
ConfigLocation: func(cfg *config) string {
190+
ConfigLocation: func(_ *config) string {
192191
// This is a bit stupid.
193192
os.Args = []string{"cmd", "--help"}
194193
return "data/empty.toml"

util/file_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func TestMakeUniqFile(t *testing.T) {
155155

156156
func Test_mkUniq(t *testing.T) {
157157
dir := t.TempDir()
158-
name, err := mkUniq(dir+"/", func(name string) error {
158+
name, err := mkUniq(dir+"/", func(_ string) error {
159159
return nil
160160
})
161161
if err != nil {

0 commit comments

Comments
 (0)