From 1bd691625f3625957c1a6d758408854ad7109bf8 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 24 Nov 2023 11:45:18 +1300 Subject: [PATCH] refactor: upgrade golangci-lint (#673) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that the `SBOMReader` refactor wasn't required for this, but my IDE flagged it so I just included it here 🤷 --- .github/workflows/lint-action/action.yml | 2 +- cmd/osv-scanner/main_test.go | 3 ++- internal/sbom/sbom.go | 12 ++++++------ pkg/depsdev/license.go | 4 ++-- pkg/lockfile/extractor.go | 2 +- scripts/run_lints.sh | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint-action/action.yml b/.github/workflows/lint-action/action.yml index 245842e5a9..0eb6f39d84 100644 --- a/.github/workflows/lint-action/action.yml +++ b/.github/workflows/lint-action/action.yml @@ -22,6 +22,6 @@ runs: uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.54.2 + version: v1.55.2 # https://github.com/golangci/golangci-lint-action/issues/135 skip-pkg-cache: true diff --git a/cmd/osv-scanner/main_test.go b/cmd/osv-scanner/main_test.go index d105487e34..05469c15dc 100644 --- a/cmd/osv-scanner/main_test.go +++ b/cmd/osv-scanner/main_test.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "regexp" + "strconv" "strings" "testing" @@ -59,7 +60,7 @@ func dedent(t *testing.T, str string) string { } } - re := regexp.MustCompile(`\n[\t ]{` + fmt.Sprint(size) + `}`) + re := regexp.MustCompile(`\n[\t ]{` + strconv.Itoa(size) + `}`) str = re.ReplaceAllString(str, "\n") } diff --git a/internal/sbom/sbom.go b/internal/sbom/sbom.go index a35a3d65cc..f6b5b81086 100644 --- a/internal/sbom/sbom.go +++ b/internal/sbom/sbom.go @@ -11,16 +11,16 @@ type Identifier struct { PURL string } -// SBOMReader is an interface for all SBOM providers. -type SBOMReader interface { +// Reader is an interface for all SBOM providers. +type Reader interface { Name() string - // Checks if the file path is a standard recognized file name - MatchesRecognizedFileNames(string) bool - GetPackages(io.ReadSeeker, func(Identifier) error) error + // MatchesRecognizedFileNames checks if the file path is a standard recognized file name + MatchesRecognizedFileNames(path string) bool + GetPackages(r io.ReadSeeker, callback func(Identifier) error) error } var ( - Providers = []SBOMReader{ + Providers = []Reader{ &SPDX{}, &CycloneDX{}, } diff --git a/pkg/depsdev/license.go b/pkg/depsdev/license.go index 3a99ac4c5d..8ec5e849ca 100644 --- a/pkg/depsdev/license.go +++ b/pkg/depsdev/license.go @@ -81,8 +81,8 @@ func MakeVersionRequests(queries []*depsdevpb.GetVersionRequest) ([][]models.Lic return err } - ls := make([]models.License, len(resp.Licenses)) - for j, license := range resp.Licenses { + ls := make([]models.License, len(resp.GetLicenses())) + for j, license := range resp.GetLicenses() { ls[j] = models.License(license) } if len(ls) == 0 { diff --git a/pkg/lockfile/extractor.go b/pkg/lockfile/extractor.go index f3349e41e0..7e05765175 100644 --- a/pkg/lockfile/extractor.go +++ b/pkg/lockfile/extractor.go @@ -18,7 +18,7 @@ type DepFile interface { // current DepFile if the provided path is relative. // // If the path is an absolute path, then it is opened absolutely. - Open(string) (NestedDepFile, error) + Open(path string) (NestedDepFile, error) Path() string } diff --git a/scripts/run_lints.sh b/scripts/run_lints.sh index 0bc3e767ff..f23aa2a83a 100755 --- a/scripts/run_lints.sh +++ b/scripts/run_lints.sh @@ -2,4 +2,4 @@ set -ex -go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 run ./... --max-same-issues 0 +go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 run ./... --max-same-issues 0