Repository: sonatype-nexus-community/nancy (go)

Issue:
Introduce go linting to CI process
* **What are you trying to do?**

The issue that spurred PR #59 was found via running a go linter. https://github.com/golangci/golangci-lint to be specific. But we should get this or at a dead minimum `go vet` in place as part of our CI pipeline. This will help our code suck less. 

* **What feature or behavior is this required for?**
Doing linting on all PRs and master builds

* **How could we solve this issue? (Not knowing is okay!)**
Introduce `golangci-lint` or `go vet` as part of the build process. 

* **Anything else?**
`golangci-lint` has a lot of configurability as well as lots more linters/tools that come with that have the ability to help find and fix issues. Whereas `go vet` is a do one thing and only that thing. It did point out the same issue fixed as part of #59 but that was it. 

`golangci-lint` does in fact run `go vet` as part of its process. 

The defaults for `golangci-lint` are as follows : 
![image](https://user-images.githubusercontent.com/1099906/70584342-c608e880-1b8e-11ea-9280-22be1f718535.png)

@flimzy mentioned that he likes to configure some others that are not enabled by default so hopefully they will fill us in on those details and we can discuss further. 

I currently dont have strong opinions on what we enable at the moment. At this point getting either in place or even a different option is better than the nothing we have today.

cc @bhamail / @DarthHater / @flimzy 


Pull request:
Dryer lint can be good
Adding golangci-lint to the project as well as start to use Make to encapsulate all build things. 

It relates to the following issue #s:
* Fixes #65 

cc @bhamail / @DarthHater / @flimzy 


Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 3685b00..0195780 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -21,15 +21,11 @@ jobs:
       - restore_cache:
           keys:
             - go-mod-v1-{{ checksum "go.sum" }}
-      - run: go mod download
-      - run: go mod tidy
       - run: go get -u github.com/jstemmer/go-junit-report
-      - run: go build
-      - run: go test ./... -v 2>&1 -p=1 | go-junit-report > $TEST_RESULTS/gotest/report.xml
-      - run: cd packages/testdata && ../../nancy Gopkg.lock && cd -
-      - run: ./nancy go.sum
-      - run: go list -m all | ./nancy
-      - run: go list -m all > deps.out && ./nancy < deps.out
+      - run: make deps
+      - run: make ci-lint
+      - run: make test | go-junit-report > $TEST_RESULTS/gotest/report.xml
+      - run: make integration-test
       - save_cache:
           key: go-mod-v1-{{ checksum "go.sum" }}
           paths:
diff --git a/.gitignore b/.gitignore
index 6952ac2..54b94a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
 vendor
 nancy
+nancy*amd64*
 .DS_Store
+.cache
 
 #IntelliJ
 .idea
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9245882
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,45 @@
+# Go parameters
+GO_BUILD_FLAGS=GO111MODULE=on CGO_ENABLED=0
+GOCMD=go
+GOBUILD=$(GOCMD) build
+GOCLEAN=$(GOCMD) clean
+GOTEST=$(GOCMD) test
+BINARY_NAME=nancy
+BUILD_VERSION_LOCATION=github.com/sonatype-nexus-community/nancy/buildversion
+GOLANGCI_VERSION=v1.24.0
+GOLANGCI_LINT_DOCKER=golangci/golangci-lint:$(GOLANGCI_VERSION)
+LINT_CMD=golangci-lint cache status --color always && golangci-lint run --timeout 5m --color always -v --max-same-issues 10
+
+all: deps test lint build
+
+.PHONY: lint clean deps build test integration-test package
+
+lint:
+	docker run --rm -v $$(pwd):/app -v $$(pwd)/.cache:/root/.cache -w /app $(GOLANGCI_LINT_DOCKER) /bin/sh -c "$(LINT_CMD)"
+
+ci-lint:
+	curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_VERSION)
+	$(LINT_CMD)
+
+clean:
+	$(GOCLEAN)
+	rm -rf .cache
+	rm -f $(BINARY_NAME)
+	rm -f $(BINARY_NAME)-*amd64*
+
+deps:
+	$(GOCMD) mod download
+	$(GOCMD) mod verify
+	$(GOCMD) mod tidy
+
+build: 
+	$(GO_BUILD_FLAGS) $(GOBUILD) -o $(BINARY_NAME) -v
+
+test: build
+	$(GOTEST) -v -count=1 -p=1 ./... 2>&1
+
+integration-test: build
+	cd packages/testdata && ../../$(BINARY_NAME) Gopkg.lock && cd -
+	./$(BINARY_NAME) go.sum
+	go list -m all | ./$(BINARY_NAME)
+	go list -m all > deps.out && ./$(BINARY_NAME) < deps.out
diff --git a/README.md b/README.md
index 4519316..8e0bf75 100644
--- a/README.md
+++ b/README.md
@@ -419,9 +419,8 @@ At current time you have a few options:
 ### Build from source
 
 * Clone the project `git clone github.com/sonatype-nexus-community/nancy`
-* Depending on your env you may have to enable go.mod `export GO111MODULE=on`
-* In the root of the project `go test ./...`
-* If tests checkout go ahead and run `go build`.
+* In the root of the project run `make`
+  * This will execute multiple targets so if you want to short circuit some of that process you can also just run `make build` to get the binary without running tests, linting, etc
 * Use that binary where ever your heart so desires!
 
 ### Download release binary
@@ -437,7 +436,7 @@ $ curl -o /path/where/you/want/nancy \
 
 `nancy` is written using Golang 1.13, so it is best you start there.
 
-Tests can be run like `go test ./... -v`
+Tests can be run like this `make test`
 
 ### Release Process
 
diff --git a/audit/auditlogtextformatter.go b/audit/auditlogtextformatter.go
index b9b90e3..4e6596a 100644
--- a/audit/auditlogtextformatter.go
+++ b/audit/auditlogtextformatter.go
@@ -76,8 +76,6 @@ func logVulnerablePackage(sb *strings.Builder, noColor bool, idx int, packageCou
 				coordinate.Vulnerabilities[j].Reference))
 		}
 	}
-
-	return
 }
 
 func (f *AuditLogTextFormatter) Format(entry *Entry) ([]byte, error) {
diff --git a/audit/csvformatter.go b/audit/csvformatter.go
index 76421ce..cadc736 100644
--- a/audit/csvformatter.go
+++ b/audit/csvformatter.go
@@ -21,6 +21,7 @@ import (
 	"strconv"
 
 	. "github.com/sirupsen/logrus"
+	"github.com/sonatype-nexus-community/nancy/customerrors"
 	"github.com/sonatype-nexus-community/nancy/types"
 )
 
@@ -53,33 +54,33 @@ func (f *CsvFormatter) Format(entry *Entry) ([]byte, error) {
 		var buf bytes.Buffer
 		w := csv.NewWriter(&buf)
 
-		w.Write([]string{"Summary"})
-		w.Write(summaryHeader)
-		w.Write(summaryRow)
+		f.write(w, []string{"Summary"})
+		f.write(w, summaryHeader)
+		f.write(w, summaryRow)
 
 		if !*f.Quiet {
 			invalidCount := len(invalidEntries)
 			if invalidCount > 0 {
-				w.Write([]string{""})
-				w.Write([]string{"Invalid Package(s)"})
-				w.Write(invalidHeader)
+				f.write(w, []string{""})
+				f.write(w, []string{"Invalid Package(s)"})
+				f.write(w, invalidHeader)
 				for i := 1; i <= invalidCount; i++ {
 					invalidEntry := invalidEntries[i-1]
-					w.Write([]string{"[" + strconv.Itoa(i) + "/" + strconv.Itoa(invalidCount) + "]", invalidEntry.Coordinates, "Does not use SemVer"})
+					f.write(w, []string{"[" + strconv.Itoa(i) + "/" + strconv.Itoa(invalidCount) + "]", invalidEntry.Coordinates, "Does not use SemVer"})
 				}
 			}
 		}
 
 		if !*f.Quiet || numVulnerable > 0 {
-			w.Write([]string{""})
-			w.Write([]string{"Audited Package(s)"})
-			w.Write(auditedHeader)
+			f.write(w, []string{""})
+			f.write(w, []string{"Audited Package(s)"})
+			f.write(w, auditedHeader)
 		}
 		for i := 1; i <= len(auditedEntries); i++ {
 			auditEntry := auditedEntries[i-1]
 			if auditEntry.IsVulnerable() || !*f.Quiet {
 				jsonVulns, _ := json.Marshal(auditEntry.Vulnerabilities)
-				w.Write([]string{"[" + strconv.Itoa(i) + "/" + strconv.Itoa(packageCount) + "]", auditEntry.Coordinates, strconv.FormatBool(auditEntry.IsVulnerable()), strconv.Itoa(len(auditEntry.Vulnerabilities)), string(jsonVulns)})
+				f.write(w, []string{"[" + strconv.Itoa(i) + "/" + strconv.Itoa(packageCount) + "]", auditEntry.Coordinates, strconv.FormatBool(auditEntry.IsVulnerable()), strconv.Itoa(len(auditEntry.Vulnerabilities)), string(jsonVulns)})
 			}
 		}
 
@@ -91,3 +92,8 @@ func (f *CsvFormatter) Format(entry *Entry) ([]byte, error) {
 	}
 
 }
+
+func (f *CsvFormatter) write(w *csv.Writer, line []string) {
+	err := w.Write(line)
+	customerrors.Check(err, "Failed to write data to csv")
+}
diff --git a/configuration/parse.go b/configuration/parse.go
index 6d0368c..3f55e51 100644
--- a/configuration/parse.go
+++ b/configuration/parse.go
@@ -15,7 +15,6 @@ package configuration
 
 import (
 	"bufio"
-	"errors"
 	"flag"
 	"fmt"
 	"io/ioutil"
@@ -215,7 +214,7 @@ func getModfilePath() (modfilepath string, err error) {
 	if flag.CommandLine.NArg() > 0 {
 		nonFlagArgs := flag.CommandLine.Args()
 		if len(nonFlagArgs) != 1 {
-			return modfilepath, errors.New(fmt.Sprintf("wrong number of modfile paths: %s", nonFlagArgs))
+			return modfilepath, fmt.Errorf("wrong number of modfile paths: %s", nonFlagArgs)
 		}
 		for _, nonFlagArg := range nonFlagArgs {
 			return nonFlagArg, err
@@ -260,7 +259,7 @@ func determineIfLineIsExclusion(ogLine string, config *Configuration) error {
 		if until != nil {
 			parseDate, err := time.Parse("2006-01-02", strings.TrimSpace(until[2]))
 			if err != nil {
-				return errors.New(fmt.Sprintf("failed to parse until at line '%s'. Expected format is 'until=yyyy-MM-dd'", ogLine))
+				return fmt.Errorf("failed to parse until at line %q. Expected format is 'until=yyyy-MM-dd'", ogLine)
 			}
 			if parseDate.After(time.Now()) {
 				config.CveList.Cves = append(config.CveList.Cves, cveOnly)
diff --git a/go.mod b/go.mod
index 9ba91e2..3fbd541 100644
--- a/go.mod
+++ b/go.mod
@@ -14,7 +14,7 @@ require (
 	github.com/dustin/go-humanize v1.0.0 // indirect
 	github.com/golang/dep v0.5.4
 	github.com/golang/protobuf v1.2.0 // indirect
-	github.com/google/go-cmp v0.3.1 // indirect
+	github.com/google/go-cmp v0.4.0 // indirect
 	github.com/jarcoal/httpmock v1.0.4
 	github.com/jmank88/nuts v0.3.0 // indirect
 	github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
diff --git a/go.sum b/go.sum
index d119f50..0e61c79 100644
--- a/go.sum
+++ b/go.sum
@@ -29,8 +29,8 @@ github.com/golang/dep v0.5.4 h1:WfV5qbGwsBNUDhk+pfI6emWm7SdDFsnSWkqCMNG3BRs=
 github.com/golang/dep v0.5.4/go.mod h1:6RZ2Wai7dSWk7qL55sDYk+8UPFqcW7all2KDBraPPFA=
 github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
-github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/jarcoal/httpmock v1.0.4 h1:jp+dy/+nonJE4g4xbVtl9QdrUNbn6/3hDT5R4nDIZnA=
 github.com/jarcoal/httpmock v1.0.4/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik=
 github.com/jmank88/nuts v0.3.0 h1:UZUboV1LXVkBUTHLRTEZrDfAL7QYgj9jEsBCiJHrxEM=
@@ -72,6 +72,8 @@ golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa h1:mQTN3ECqfsViCNBgq+A40vdwh
 golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
diff --git a/iq/iq.go b/iq/iq.go
index 1ac2ed9..9e20354 100644
--- a/iq/iq.go
+++ b/iq/iq.go
@@ -127,6 +127,7 @@ func getInternalApplicationID(applicationID string) (string, error) {
 		fmt.Sprintf("%s%s%s", localConfig.Server, internalApplicationIDURL, applicationID),
 		nil,
 	)
+	customerrors.Check(err, "Request to get internal application id failed")
 
 	req.SetBasicAuth(localConfig.User, localConfig.Token)
 	req.Header.Set("User-Agent", useragent.GetUserAgent())
@@ -175,6 +176,7 @@ func submitToThirdPartyAPI(sbom string, internalID string) string {
 		url,
 		bytes.NewBuffer([]byte(sbom)),
 	)
+	customerrors.Check(err, "Could not POST to Nexus iQ Third Party API")
 
 	req.SetBasicAuth(localConfig.User, localConfig.Token)
 	req.Header.Set("User-Agent", useragent.GetUserAgent())
@@ -191,7 +193,8 @@ func submitToThirdPartyAPI(sbom string, internalID string) string {
 		customerrors.Check(err, "There was an issue submitting your sbom to the Nexus IQ Third Party API")
 
 		var response thirdPartyAPIResult
-		json.Unmarshal(bodyBytes, &response)
+		err = json.Unmarshal(bodyBytes, &response)
+		customerrors.Check(err, "Could not unmarshal response from iQ server")
 		return response.StatusURL
 	}
 	bodyBytes, err := ioutil.ReadAll(resp.Body)
@@ -218,6 +221,7 @@ func pollIQServer(statusURL string, finished chan bool, maxRetries int) {
 
 	client := &http.Client{}
 	req, err := http.NewRequest("GET", statusURL, nil)
+	customerrors.Check(err, "Could not poll iQ server")
 
 	req.SetBasicAuth(localConfig.User, localConfig.Token)
 
@@ -237,7 +241,8 @@ func pollIQServer(statusURL string, finished chan bool, maxRetries int) {
 		customerrors.Check(err, "There was an error with processing the response from polling Nexus IQ Server")
 
 		var response types.StatusURLResult
-		json.Unmarshal(bodyBytes, &response)
+		err = json.Unmarshal(bodyBytes, &response)
+		customerrors.Check(err, "Could not unmarshal response from iQ server")
 		statusURLResp = response
 		if response.IsError {
 			finished <- true
diff --git a/logger/logger.go b/logger/logger.go
index 9ff8554..e4700a7 100644
--- a/logger/logger.go
+++ b/logger/logger.go
@@ -46,7 +46,7 @@ func doInit(args []string) {
 
 	file, err := os.OpenFile(GetLogFileLocation(), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
 	if err != nil {
-		fmt.Print(err)
+		fmt.Printf("Could not open log file. error: %v\n", err)
 	}
 
 	LogLady.Out = file
@@ -82,7 +82,10 @@ func useTestLogFile(args []string) bool {
 // GetLogFileLocation will return the location on disk of the log file
 func GetLogFileLocation() (result string) {
 	result, _ = os.UserHomeDir()
-	os.MkdirAll(path.Join(result, types.OssIndexDirName), os.ModePerm)
+	err := os.MkdirAll(path.Join(result, types.OssIndexDirName), os.ModePerm)
+	if err != nil {
+		fmt.Printf("Failed to make all dirs needed to be able to store log file. error: %v\n", err)
+	}
 	result = path.Join(result, types.OssIndexDirName, DefaultLogFile)
 	return
 }
diff --git a/packages/mod.go b/packages/mod.go
index 64e9251..01c4a53 100644
--- a/packages/mod.go
+++ b/packages/mod.go
@@ -30,8 +30,7 @@ type Mod struct {
 
 func (m Mod) ExtractPurlsFromManifest() (purls []string) {
 	for _, s := range m.ProjectList.Projects {
-		var version string
-		version = strings.Replace(s.Version, "v", "", -1)
+		version := strings.Replace(s.Version, "v", "", -1)
 
 		if len(version) > 0 { // There must be a version we can use
 			var purl = "pkg:" + convertGopkgNameToPurl(s.Name) + "@" + version
@@ -69,7 +68,7 @@ func removeDuplicates(purls []string) (dedupedPurls []string) {
 	encountered := map[string]bool{}
 
 	for _, v := range purls {
-		if encountered[v] == true {
+		if encountered[v] {
 			LogLady.WithField("dep", v).Debug("Found duplicate dependency, eliminating it")
 		} else {
 			LogLady.WithField("dep", v).Debug("Unique dependency, adding it")
diff --git a/useragent/useragent.go b/useragent/useragent.go
index 0154f97..1610a4c 100644
--- a/useragent/useragent.go
+++ b/useragent/useragent.go
@@ -43,7 +43,7 @@ func GetUserAgent() string {
 	//
 	// double underscore "__" delimits Name/Version
 	// triple underscore "___" delimits currentCaller/priorCaller/priorPriorCaller
-	callTree := os.Getenv("SC_CALLER_INFO")
+	callTree := getCallerInfo()
 	if checkForCIEnvironment() {
 		return checkCIEnvironments(callTree)
 	}
@@ -105,18 +105,12 @@ func checkForCIEnvironment() bool {
 
 func checkIfJenkins() bool {
 	s := os.Getenv("JENKINS_HOME")
-	if s != "" {
-		return true
-	}
-	return false
+	return s != ""
 }
 
 func checkIfGitHub() bool {
 	s := os.Getenv("GITHUB_ACTIONS")
-	if s != "" {
-		return true
-	}
-	return false
+	return s != ""
 }
 
 // Returns info from SC_CALLER_INFO, example: bitbucket-nancy-pipe-0.1.9
@@ -132,8 +126,5 @@ func getGitHubActionID() string {
 
 func checkForCISystem(system string) bool {
 	s := os.Getenv(system)
-	if s != "" {
-		return true
-	}
-	return false
+	return s != ""
 }


Test patch:
diff --git a/configuration/parse_test.go b/configuration/parse_test.go
index ede34ca..81b02e4 100644
--- a/configuration/parse_test.go
+++ b/configuration/parse_test.go
@@ -78,8 +78,8 @@ func TestConfigParse(t *testing.T) {
 		"exclude vulnerabilities doesn't need to be passed if default value is used": {args: []string{"/tmp/go13.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"DEF-111", "DEF-222"}}, Formatter: defaultAuditLogFormatter, Path: "/tmp/go13.sum"}, expectedErr: nil},
 		"exclude vulnerabilities when has comments":                                  {args: []string{"-exclude-vulnerability-file=" + commentedFile.Name(), "/tmp/go14.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"CVN-111", "CVN-123", "CVN-543"}}, Path: "/tmp/go14.sum", Formatter: defaultAuditLogFormatter}, expectedErr: nil},
 		"exclude vulnerabilities when has untils":                                    {args: []string{"-exclude-vulnerability-file=" + untilsFile.Name(), "/tmp/go15.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{Cves: []string{"NO-UNTIL-888", "MUST-BE-IGNORED-999", "MUST-BE-IGNORED-1999"}}, Path: "/tmp/go15.sum", Formatter: defaultAuditLogFormatter}, expectedErr: nil},
-		"exclude vulnerabilities when has invalid value in untils":                   {args: []string{"-exclude-vulnerability-file=" + invalidUntilsFile.Name(), "/tmp/go16.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{}, Path: "/tmp/go16.sum", Formatter: defaultAuditLogFormatter}, expectedErr: errors.New("failed to parse until at line '" + invalidUntilLine + "'. Expected format is 'until=yyyy-MM-dd'")},
-		"exclude vulnerabilities when has invalid date in untils":                    {args: []string{"-exclude-vulnerability-file=" + invalidDateUntilsFile.Name(), "/tmp/go17.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{}, Path: "/tmp/go17.sum", Formatter: defaultAuditLogFormatter}, expectedErr: errors.New("failed to parse until at line '" + invalidDateUntilLine + "'. Expected format is 'until=yyyy-MM-dd'")},
+		"exclude vulnerabilities when has invalid value in untils":                   {args: []string{"-exclude-vulnerability-file=" + invalidUntilsFile.Name(), "/tmp/go16.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{}, Path: "/tmp/go16.sum", Formatter: defaultAuditLogFormatter}, expectedErr: errors.New("failed to parse until at line \"" + invalidUntilLine + "\". Expected format is 'until=yyyy-MM-dd'")},
+		"exclude vulnerabilities when has invalid date in untils":                    {args: []string{"-exclude-vulnerability-file=" + invalidDateUntilsFile.Name(), "/tmp/go17.sum"}, expectedConfig: Configuration{CveList: types.CveListFlag{}, Path: "/tmp/go17.sum", Formatter: defaultAuditLogFormatter}, expectedErr: errors.New("failed to parse until at line \"" + invalidDateUntilLine + "\". Expected format is 'until=yyyy-MM-dd'")},
 		"output of json":              {args: []string{"-output=json"}, expectedConfig: Configuration{UseStdIn: true, Formatter: &audit.JsonFormatter{}}, expectedErr: nil},
 		"output of json modfile":      {args: []string{"-output=json", "/tmp/go14.sum"}, expectedConfig: Configuration{Formatter: &audit.JsonFormatter{}, Path: "/tmp/go14.sum"}, expectedErr: nil},
 		"output of json pretty print": {args: []string{"-output=json-pretty", "/tmp/go15.sum"}, expectedConfig: Configuration{Formatter: &audit.JsonFormatter{PrettyPrint: true}, Path: "/tmp/go15.sum"}, expectedErr: nil},
diff --git a/packages/dep_int_test.go b/packages/dep_int_test.go
index 0e0179b..d8d24ae 100644
--- a/packages/dep_int_test.go
+++ b/packages/dep_int_test.go
@@ -17,6 +17,7 @@ import (
 	"fmt"
 	"github.com/Flaque/filet"
 	"github.com/golang/dep"
+	"github.com/stretchr/testify/require"
 	"io/ioutil"
 	"log"
 	"os"
@@ -25,6 +26,7 @@ import (
 
 func TestExtractPurlsFromManifestUsingDep(t *testing.T) {
 	path, projectDir, err := doGoPathSimulatedSetup(t)
+	require.NoError(t, err)
 	defer filet.CleanUp(t)
 
 	ctx := dep.Ctx{
@@ -33,33 +35,31 @@ func TestExtractPurlsFromManifestUsingDep(t *testing.T) {
 		Out:        log.New(os.Stdout, "", 0),
 		Err:        log.New(os.Stderr, "", 0),
 	}
-	project, err := ctx.LoadProject()
-	if err != nil {
-		t.Error(err)
-	} else {
-		purls, invalidPurls := ExtractPurlsUsingDep(project)
-		if len(invalidPurls) != 7 {
-			t.Errorf("Number of invalid purls not as expected. Expected : %d, Got %d", 7, len(purls))
-		}
-		if len(purls) != 7 {
-			t.Errorf("Number of purls not as expected. Expected : %d, Got %d", 7, len(purls))
-		}
-		assertPurlFound("pkg:golang/github.com/Masterminds/semver@2.x", invalidPurls, t)
-		assertPurlFound("pkg:golang/github.com/armon/go-radix@master", invalidPurls, t)
-		assertPurlFound("pkg:golang/github.com/nightlyone/lockfile@master", invalidPurls, t)
-		assertPurlFound("pkg:golang/github.com/sdboyer/constext@master", invalidPurls, t)
-		assertPurlFound("pkg:golang/golang.org/x/net@master", invalidPurls, t)
-		assertPurlFound("pkg:golang/golang.org/x/sync@master", invalidPurls, t)
-		assertPurlFound("pkg:golang/golang.org/x/sys@master", invalidPurls, t)
+	project, err2 := ctx.LoadProject()
+	require.NoError(t, err2)
 
-		assertPurlFound("pkg:golang/github.com/go-yaml/yaml@2", purls, t)
-		assertPurlFound("pkg:golang/github.com/Masterminds/vcs@1.11.1", purls, t)
-		assertPurlFound("pkg:golang/github.com/boltdb/bolt@1.3.1", purls, t)
-		assertPurlFound("pkg:golang/github.com/golang/protobuf@1.0.0", purls, t)
-		assertPurlFound("pkg:golang/github.com/jmank88/nuts@0.3.0", purls, t)
-		assertPurlFound("pkg:golang/github.com/pelletier/go-toml@1.2.0", purls, t)
-		assertPurlFound("pkg:golang/github.com/pkg/errors@0.8.0", purls, t)
+	purls, invalidPurls := ExtractPurlsUsingDep(project)
+	if len(invalidPurls) != 7 {
+		t.Errorf("Number of invalid purls not as expected. Expected : %d, Got %d", 7, len(purls))
 	}
+	if len(purls) != 7 {
+		t.Errorf("Number of purls not as expected. Expected : %d, Got %d", 7, len(purls))
+	}
+	assertPurlFound("pkg:golang/github.com/Masterminds/semver@2.x", invalidPurls, t)
+	assertPurlFound("pkg:golang/github.com/armon/go-radix@master", invalidPurls, t)
+	assertPurlFound("pkg:golang/github.com/nightlyone/lockfile@master", invalidPurls, t)
+	assertPurlFound("pkg:golang/github.com/sdboyer/constext@master", invalidPurls, t)
+	assertPurlFound("pkg:golang/golang.org/x/net@master", invalidPurls, t)
+	assertPurlFound("pkg:golang/golang.org/x/sync@master", invalidPurls, t)
+	assertPurlFound("pkg:golang/golang.org/x/sys@master", invalidPurls, t)
+
+	assertPurlFound("pkg:golang/github.com/go-yaml/yaml@2", purls, t)
+	assertPurlFound("pkg:golang/github.com/Masterminds/vcs@1.11.1", purls, t)
+	assertPurlFound("pkg:golang/github.com/boltdb/bolt@1.3.1", purls, t)
+	assertPurlFound("pkg:golang/github.com/golang/protobuf@1.0.0", purls, t)
+	assertPurlFound("pkg:golang/github.com/jmank88/nuts@0.3.0", purls, t)
+	assertPurlFound("pkg:golang/github.com/pelletier/go-toml@1.2.0", purls, t)
+	assertPurlFound("pkg:golang/github.com/pkg/errors@0.8.0", purls, t)
 }
 
 func assertPurlFound(expectedPurl string, result []string, t *testing.T) {
diff --git a/types/types_test.go b/types/types_test.go
index 7d962ea..01949ef 100644
--- a/types/types_test.go
+++ b/types/types_test.go
@@ -19,7 +19,7 @@ func TestCveRemoveWhiteSpace(t *testing.T) {
 	cve := CveListFlag{}
 	test := "CVE-123, CVE-456, CVE-0020-20"
 	result := []string{"CVE-123", "CVE-456", "CVE-0020-20"}
-	cve.Set(test)
+	_ = cve.Set(test)
 
 	if len(cve.Cves) != 3 {
 		t.Errorf("Split unsuccessful")