Skip to content

Commit

Permalink
refactor: update golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Rath committed Aug 24, 2023
1 parent ea16158 commit 73513b3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.47
version: v1.54
go-fmt:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ linters:
- wsl # disagree with, for now
- ireturn # disagree with, sort of
- nonamedreturns # they have their uses
- depguard # does not make any sense
presets:
- bugs
- comment
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test-with-coverage:
lint: lint-with-golangci-lint lint-with-go-fmt

lint-with-golangci-lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.47.3 run ./... --max-same-issues 0
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.1 run ./... --max-same-issues 0

lint-with-go-fmt:
gofmt -s -d */**.go
Expand Down
10 changes: 5 additions & 5 deletions pkg/database/api-check.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (db APIDB) checkBatch(pkgs []internal.PackageDetails) ([][]ObjectWithID, er
}{queries})

if err != nil {
return [][]ObjectWithID{}, fmt.Errorf("%v: %w", ErrAPICouldNotMarshalPayload, err)
return [][]ObjectWithID{}, fmt.Errorf("%w: %w", ErrAPICouldNotMarshalPayload, err)
}

req, err := http.NewRequestWithContext(
Expand All @@ -70,12 +70,12 @@ func (db APIDB) checkBatch(pkgs []internal.PackageDetails) ([][]ObjectWithID, er
)

if err != nil {
return [][]ObjectWithID{}, fmt.Errorf("%v: %w", ErrAPIRequestInvalid, err)
return [][]ObjectWithID{}, fmt.Errorf("%w: %w", ErrAPIRequestInvalid, err)
}

resp, err := http.DefaultClient.Do(req)
if err != nil {
return [][]ObjectWithID{}, fmt.Errorf("%v: %w", ErrAPIRequestFailed, err)
return [][]ObjectWithID{}, fmt.Errorf("%w: %w", ErrAPIRequestFailed, err)
}

defer resp.Body.Close()
Expand All @@ -96,7 +96,7 @@ func (db APIDB) checkBatch(pkgs []internal.PackageDetails) ([][]ObjectWithID, er

if err != nil {
return [][]ObjectWithID{}, fmt.Errorf(
"%v (%s %s): %w",
"%w (%s %s): %w",
ErrAPIUnreadableResponse,
resp.Request.Method,
resp.Request.URL,
Expand All @@ -114,7 +114,7 @@ func (db APIDB) checkBatch(pkgs []internal.PackageDetails) ([][]ObjectWithID, er

if err != nil {
return [][]ObjectWithID{}, fmt.Errorf(
"%v (%s %s): %w",
"%w (%s %s): %w",
ErrAPIResponseNotJSON,
resp.Request.Method,
resp.Request.URL,
Expand Down
8 changes: 4 additions & 4 deletions pkg/database/api-fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func (db APIDB) Fetch(id string) (OSV, error) {
)

if err != nil {
return osv, fmt.Errorf("%v: %w", ErrAPIRequestInvalid, err)
return osv, fmt.Errorf("%w: %w", ErrAPIRequestInvalid, err)
}

resp, err := http.DefaultClient.Do(req)
if err != nil {
return osv, fmt.Errorf("%v: %w", ErrAPIRequestFailed, err)
return osv, fmt.Errorf("%w: %w", ErrAPIRequestFailed, err)
}

defer resp.Body.Close()
Expand All @@ -55,7 +55,7 @@ func (db APIDB) Fetch(id string) (OSV, error) {

if err != nil {
return osv, fmt.Errorf(
"%v (%s %s): %w",
"%w (%s %s): %w",
ErrAPIUnreadableResponse,
resp.Request.Method,
resp.Request.URL,
Expand All @@ -67,7 +67,7 @@ func (db APIDB) Fetch(id string) (OSV, error) {

if err != nil {
return osv, fmt.Errorf(
"%v (%s %s): %w",
"%w (%s %s): %w",
ErrAPIResponseNotJSON,
resp.Request.Method,
resp.Request.URL,
Expand Down
8 changes: 4 additions & 4 deletions pkg/database/zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func (db *ZipDB) Identifier() string { return db.identifier }

// Cache stores the OSV database archive for re-use
type Cache struct {
URL string
ETag string
Date string
Body []byte
URL string `json:"url"`
ETag string `json:"etag"`
Date string `json:"date"`
Body []byte `json:"body"`
}

var ErrOfflineDatabaseNotFound = errors.New("no offline version of the OSV database is available")
Expand Down

0 comments on commit 73513b3

Please sign in to comment.