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

Commit fb7a240

Browse files
dlespiauskogtwin
authored andcommitted
Enable some static checking with golangci-lint and fixes a few problems found by the tool (#131)
* [redhat] Fix a couple of typo in the JSON struct tags * [cmd2cve] Remove unused field member * [rpm] Make ToWFN actually propagate the error * [redhat] Remove unused field in struct * [rbs2nvd] Remove unusued const The UserAgent is setup as a string litteral a few lines below. * [ci]: Enable a few linter passes with golangci-lint * [ci] Remove the typecheck pass to work around a golangci-lint upstream bug golangci/golangci-lint#944 * ci: Allow the go: master build to fail
1 parent 7d9adf6 commit fb7a240

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

.travis.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
language: go
22
dist: xenial
33

4-
go:
5-
- 1.13
6-
- 1.x
7-
- master
4+
jobs:
5+
include:
6+
- go: 1.13
7+
- go: 1.x
8+
- go: master
9+
allow_failures:
10+
- go: master
811

912
services:
1013
mysql
1114

1215
before_install:
1316
- sudo apt-get install -y rpm build-essential debhelper dh-make fakeroot zip
1417
- mysql -e 'CREATE DATABASE vulndb;'
18+
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.1
1519

1620
env:
1721
- MYSQL_TEST_DSN=root@/vulndb
1822

1923
script:
2024
- go get -v -t -u -d ./...
25+
- golangci-lint run ./... --disable-all -E gosimple -E govet -E ineffassign -E staticcheck -E structcheck -E varcheck
2126
- go test -v ./...
2227

2328
before_deploy:

cmd/cpe2cve/config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ type config struct {
5959
// feeds
6060
FeedOverrides multiString // []string
6161
Feeds map[string][]string
62-
63-
provider string
6462
}
6563

6664
func (cfg *config) addFlags() {

cmd/rbs2nvd/rbs2nvd.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import (
3030
)
3131

3232
const (
33-
baseURL = "https://vulndb.cyberriskanalytics.com"
34-
userAgent = "rbs2nvd"
33+
baseURL = "https://vulndb.cyberriskanalytics.com"
3534
)
3635

3736
var tokenURL = baseURL + "/oauth/token"

providers/redhat/api/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ const (
3737
// Client struct
3838
type Client struct {
3939
client.Client
40-
baseURL string
41-
userAgent string
40+
baseURL string
4241
}
4342

4443
// NewClient creates an object which is used to query the RedHat API

providers/redhat/schema/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type CVEList []struct {
2929

3030
type CVE struct {
3131
Name string `json:"name,omitempty"`
32-
ThreatSeverity string `json:"threat_severity,omitempty,omitempty"`
32+
ThreatSeverity string `json:"threat_severity,omitempty"`
3333
PublicDate string `json:"public_date,omitempty"`
3434
Bugzilla *struct {
3535
Description string `json:"description,omitempty"`
@@ -59,7 +59,7 @@ type CVE struct {
5959
// the types of these are just helper types
6060

6161
AffectedRelease AffectedReleases `json:"affected_release,omitempty"`
62-
PackageState PackageStates `json:"package_state,omittempty"`
62+
PackageState PackageStates `json:"package_state,omitempty"`
6363
}
6464

6565
type AffectedRelease struct {

rpm/rpm2wfn.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
// FromRPMName parses CPE name from RPM package name
2424
func ToWFN(attr *wfn.Attributes, s string) error {
25-
var err error
2625
pkg, err := Parse(s)
2726
if err != nil {
2827
return fmt.Errorf("can't get fields from %q: %v", s, err)
@@ -35,7 +34,7 @@ func ToWFN(attr *wfn.Attributes, s string) error {
3534
"arch": &pkg.Arch,
3635
} {
3736
if *addr, err = wfn.WFNize(*addr); err != nil {
38-
err = fmt.Errorf("couldn't wfnize %s %q: %v", n, *addr, err)
37+
return fmt.Errorf("couldn't wfnize %s %q: %v", n, *addr, err)
3938
}
4039
}
4140

0 commit comments

Comments
 (0)