internal/worker: fix problems found by static checkers

Change-Id: I950c99250985b0781ca31cba304710f06d960b04
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/367796
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/worker/store/mem_store.go b/internal/worker/store/mem_store.go
index d0378e7..be04fa0 100644
--- a/internal/worker/store/mem_store.go
+++ b/internal/worker/store/mem_store.go
@@ -24,7 +24,7 @@
 // NewMemStore creates a new, empty MemStore.
 func NewMemStore() *MemStore {
 	m := &MemStore{}
-	_ = m.Clear(nil)
+	_ = m.Clear(context.Background())
 	return m
 }
 
diff --git a/internal/worker/update.go b/internal/worker/update.go
index 67832b7..2c4a767 100644
--- a/internal/worker/update.go
+++ b/internal/worker/update.go
@@ -6,7 +6,6 @@
 
 import (
 	"context"
-	"encoding/hex"
 	"encoding/json"
 	"fmt"
 	"io"
@@ -127,7 +126,7 @@
 				// No change; do nothing.
 				continue
 			}
-			added, err := handleCVE(ctx, repo, f, old, commitHash, needsIssue, tx)
+			added, err := handleCVE(repo, f, old, commitHash, needsIssue, tx)
 			if err != nil {
 				return err
 			}
@@ -149,7 +148,7 @@
 // handleCVE determines how to change the store for a single CVE.
 // The CVE will definitely be either added, if it's new, or modified, if it's
 // already in the DB.
-func handleCVE(ctx context.Context, repo *git.Repository, f repoFile, old *store.CVERecord, commitHash plumbing.Hash, needsIssue triageFunc, tx store.Transaction) (added bool, err error) {
+func handleCVE(repo *git.Repository, f repoFile, old *store.CVERecord, commitHash plumbing.Hash, needsIssue triageFunc, tx store.Transaction) (added bool, err error) {
 	defer derrors.Wrap(&err, "handleCVE(%s)", f.filename)
 
 	// Read CVE from repo.
@@ -281,18 +280,6 @@
 	return blob.Reader()
 }
 
-// hashFromString converts a hex string into a Hash.
-// Unlike plumbing.NewHash, it reports errors.
-func hashFromString(s string) (plumbing.Hash, error) {
-	b, err := hex.DecodeString(s)
-	if err != nil {
-		return plumbing.ZeroHash, err
-	}
-	var h plumbing.Hash
-	copy(h[:], b)
-	return h, nil
-}
-
 // idFromFilename extracts the CVE ID from its filename.
 func idFromFilename(name string) string {
 	return strings.TrimSuffix(path.Base(name), path.Ext(name))
diff --git a/internal/worker/update_test.go b/internal/worker/update_test.go
index 283c8cf..8ff35c6 100644
--- a/internal/worker/update_test.go
+++ b/internal/worker/update_test.go
@@ -186,13 +186,6 @@
 	return &cve, blob.Hash.String()
 }
 
-func newTestCVERecord(cve *cveschema.CVE, path, blobHash string, ref *plumbing.Reference, ts store.TriageState) *store.CVERecord {
-	r := store.NewCVERecord(cve, path, blobHash)
-	r.CommitHash = ref.Hash().String()
-	r.TriageState = ts
-	return r
-}
-
 func createCVERecords(t *testing.T, s store.Store, crs []*store.CVERecord) {
 	err := s.RunTransaction(context.Background(), func(_ context.Context, tx store.Transaction) error {
 		for _, cr := range crs {