Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Commit 22daa55

Browse files
committed
Fix linter.
What's done: * change linter from deprecated golint to revive * exclude SA5011 (deprecated strings.Title() call) -- the string passed to it is guaranteed to be ASCII * move nil-pointer check before first pointer dereferece in cvefeed/cvecache.go * proper declare-initialze syntax in providers/redhat/package_feed_test.go:feedSummary() * replace if strings.HasSuffix(..) { // manually trim suffix } with strings.TrimSuffix() in rpm/parse.go
1 parent 765883c commit 22daa55

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ jobs:
5858
# without patch version: we always use the latest patch version.
5959
version: v1.45
6060
working-directory: ${{ github.repository }}
61-
args: "--disable-all -E golint -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E varcheck -e SA5011:"
61+
args: "--disable-all -E revive -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E varcheck -e SA5011: -e SA1019:"

cvefeed/cvecache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ type cachedCVEs struct {
7070

7171
// updateResSize calculates the size of cached MatchResult and assigns it to cves.size
7272
func (cves *cachedCVEs) updateResSize(key string) {
73-
cves.size = int64(int(unsafe.Sizeof(key)) + len(key))
7473
if cves == nil {
7574
return
7675
}
76+
cves.size = int64(int(unsafe.Sizeof(key)) + len(key))
7777
cves.size += int64(unsafe.Sizeof(cves.res))
7878
for i := range cves.res {
7979
cves.size += int64(unsafe.Sizeof(cves.res[i].CVE))

providers/redhat/package_feed_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
type summary map[string][]string
2727

2828
func feedSummary(feed packageFeed) summary {
29-
var s summary = make(summary)
29+
s := make(summary)
3030
for pkg, cves := range feed {
3131
var cveNames []string
3232
for _, cve := range cves {

rpm/parse.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ func Parse(pkg string) (*Package, error) {
4343
// pkg should be name-[epoch:]version-release.arch.rpm
4444

4545
// extension
46-
if strings.HasSuffix(pkg, ".rpm") {
47-
pkg = pkg[:len(pkg)-4]
48-
}
46+
pkg = strings.TrimSuffix(pkg, ".rpm")
4947

5048
var p Package
5149

0 commit comments

Comments
 (0)