Skip to content

Commit

Permalink
fix lint errors, bump linter up to 1.52 (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobcallaway authored May 13, 2023
1 parent 3282e1a commit 7359299
Show file tree
Hide file tree
Showing 38 changed files with 56 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0
timeout-minutes: 5
with:
version: v1.51
version: v1.52
5 changes: 1 addition & 4 deletions cmd/rekor-cli/app/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ func Dump(key string, sth *util.SignedCheckpoint) error {
if err != nil {
return err
}
if err := os.WriteFile(statePath, b, 0600); err != nil {
return err
}
return nil
return os.WriteFile(statePath, b, 0600)
}

func loadStateFile() persistedState {
Expand Down
5 changes: 1 addition & 4 deletions cmd/rekor-cli/app/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ var uploadCmd = &cobra.Command{
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return err
}
if err := validateArtifactPFlags(false, false); err != nil {
return err
}
return nil
return validateArtifactPFlags(false, false)
},
Long: `This command takes the public key, signature and URL of the release artifact and uploads it to the rekor server.`,
Run: format.WrapCmd(func(args []string) (interface{}, error) {
Expand Down
5 changes: 1 addition & 4 deletions cmd/rekor-cli/app/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ var verifyCmd = &cobra.Command{
if err := viper.BindPFlags(cmd.Flags()); err != nil {
return fmt.Errorf("error initializing cmd line args: %s", err)
}
if err := validateArtifactPFlags(true, true); err != nil {
return err
}
return nil
return validateArtifactPFlags(true, true)
},
Run: format.WrapCmd(func(args []string) (interface{}, error) {
ctx := context.Background()
Expand Down
2 changes: 1 addition & 1 deletion cmd/rekor-cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import (
"github.com/sigstore/rekor/cmd/rekor-cli/app"
)

func TestCover(t *testing.T) {
func TestCover(_ *testing.T) {
app.Execute()
}
2 changes: 1 addition & 1 deletion cmd/rekor-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import (
"github.com/sigstore/rekor/cmd/rekor-server/app"
)

func TestCover(t *testing.T) {
func TestCover(_ *testing.T) {
app.Execute()
}
10 changes: 5 additions & 5 deletions pkg/api/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func signEntry(ctx context.Context, signer signature.Signer, entry models.LogEnt
}

// logEntryFromLeaf creates a signed LogEntry struct from trillian structs
func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc trillianclient.TrillianClient, leaf *trillian.LogLeaf,
func logEntryFromLeaf(ctx context.Context, signer signature.Signer, _ trillianclient.TrillianClient, leaf *trillian.LogLeaf,
signedLogRoot *trillian.SignedLogRoot, proof *trillian.Proof, tid int64, ranges sharding.LogRanges) (models.LogEntry, error) {

log.ContextLogger(ctx).Debugf("log entry from leaf %d", leaf.GetLeafIndex())
Expand Down Expand Up @@ -554,7 +554,7 @@ func retrieveUUIDFromTree(ctx context.Context, uuid string, tid int64) (models.L

// handlers for APIs that may be disabled in a given instance

func CreateLogEntryNotImplementedHandler(params entries.CreateLogEntryParams) middleware.Responder {
func CreateLogEntryNotImplementedHandler(_ entries.CreateLogEntryParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Create Entry API not enabled in this Rekor instance",
Expand All @@ -563,7 +563,7 @@ func CreateLogEntryNotImplementedHandler(params entries.CreateLogEntryParams) mi
return entries.NewCreateLogEntryDefault(http.StatusNotImplemented).WithPayload(err)
}

func GetLogEntryByIndexNotImplementedHandler(params entries.GetLogEntryByIndexParams) middleware.Responder {
func GetLogEntryByIndexNotImplementedHandler(_ entries.GetLogEntryByIndexParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Get Log Entry by Index API not enabled in this Rekor instance",
Expand All @@ -572,7 +572,7 @@ func GetLogEntryByIndexNotImplementedHandler(params entries.GetLogEntryByIndexPa
return entries.NewGetLogEntryByIndexDefault(http.StatusNotImplemented).WithPayload(err)
}

func GetLogEntryByUUIDNotImplementedHandler(params entries.GetLogEntryByUUIDParams) middleware.Responder {
func GetLogEntryByUUIDNotImplementedHandler(_ entries.GetLogEntryByUUIDParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Get Log Entry by UUID API not enabled in this Rekor instance",
Expand All @@ -581,7 +581,7 @@ func GetLogEntryByUUIDNotImplementedHandler(params entries.GetLogEntryByUUIDPara
return entries.NewGetLogEntryByUUIDDefault(http.StatusNotImplemented).WithPayload(err)
}

func SearchLogQueryNotImplementedHandler(params entries.SearchLogQueryParams) middleware.Responder {
func SearchLogQueryNotImplementedHandler(_ entries.SearchLogQueryParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Search Log Query API not enabled in this Rekor instance",
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func SearchIndexHandler(params index.SearchIndexParams) middleware.Responder {
return index.NewSearchIndexOK().WithPayload(result.Values())
}

func SearchIndexNotImplementedHandler(params index.SearchIndexParams) middleware.Responder {
func SearchIndexNotImplementedHandler(_ index.SearchIndexParams) middleware.Responder {
err := models.Error{
Code: http.StatusNotImplemented,
Message: "Search Index API not enabled in this Rekor instance",
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetPublicKeyHandler(params pubkey.GetPublicKeyParams) middleware.Responder

// handlers for APIs that may be disabled in a given instance

func GetPublicKeyNotImplementedHandler(params pubkey.GetPublicKeyParams) middleware.Responder {
func GetPublicKeyNotImplementedHandler(_ pubkey.GetPublicKeyParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Get Public Key API not enabled in this Rekor instance",
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/tlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func inactiveShardLogInfo(ctx context.Context, tid int64) (*models.InactiveShard

// handlers for APIs that may be disabled in a given instance

func GetLogInfoNotImplementedHandler(params tlog.GetLogInfoParams) middleware.Responder {
func GetLogInfoNotImplementedHandler(_ tlog.GetLogInfoParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Get Log Info API not enabled in this Rekor instance",
Expand All @@ -177,7 +177,7 @@ func GetLogInfoNotImplementedHandler(params tlog.GetLogInfoParams) middleware.Re
return tlog.NewGetLogInfoDefault(http.StatusNotImplemented).WithPayload(err)
}

func GetLogProofNotImplementedHandler(params tlog.GetLogProofParams) middleware.Responder {
func GetLogProofNotImplementedHandler(_ tlog.GetLogProofParams) middleware.Responder {
err := &models.Error{
Code: http.StatusNotImplemented,
Message: "Get Log Proof API not enabled in this Rekor instance",
Expand Down
2 changes: 1 addition & 1 deletion pkg/fuzz/fuzz_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func setArtifactFields(ff *fuzz.ConsumeFuzzer, props *types.ArtifactProperties)
}

// creates a file on disk and returns the url of it.
func createAbsFile(ff *fuzz.ConsumeFuzzer, fileName string, fileContents []byte) (*url.URL, error) {
func createAbsFile(_ *fuzz.ConsumeFuzzer, fileName string, fileContents []byte) (*url.URL, error) {
file, err := os.Create(fileName)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions pkg/generated/restapi/configure_rekor_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type apiToRecord struct {
path *string // Path to record in metrics, if any.
}

func configureFlags(api *operations.RekorServerAPI) {
func configureFlags(_ *operations.RekorServerAPI) {
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
}

Expand Down Expand Up @@ -162,15 +162,15 @@ func configureAPI(api *operations.RekorServerAPI) http.Handler {
}

// The TLS configuration before HTTPS server starts.
func configureTLS(tlsConfig *tls.Config) {
func configureTLS(_ *tls.Config) {
// Make all necessary changes to the TLS configuration here.
}

// As soon as server is initialized but not run yet, this function will be called.
// If you need to modify a config, store server instance to stop it individually later, this is the place.
// This function can be called multiple times, depending on the number of serving schemes.
// scheme value will be set accordingly: "http", "https" or "unix"
func configureServer(s *http.Server, scheme, addr string) {
func configureServer(_ *http.Server, _, _ string) {
}

// The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
Expand Down Expand Up @@ -209,7 +209,7 @@ type zapLogEntry struct {
r *http.Request
}

func (z *zapLogEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{}) {
func (z *zapLogEntry) Write(status, bytes int, _ http.Header, elapsed time.Duration, extra interface{}) {
var fields []interface{}

// follows https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry as a convention
Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/minisign/minisign.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s Signature) Verify(r io.Reader, k interface{}, opts ...sigsig.VerifyOptio
r = bytes.NewReader(h.Sum(nil))
}

return verifier.VerifySignature(bytes.NewReader(s.signature.Signature[:]), r)
return verifier.VerifySignature(bytes.NewReader(s.signature.Signature[:]), r, opts...)
}

// PublicKey Public Key that follows the minisign standard; supports signify and minisign public keys
Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/minisign/minisign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestReadSignature(t *testing.T) {
type BadReader struct {
}

func (br BadReader) Read(p []byte) (n int, err error) {
func (br BadReader) Read(_ []byte) (n int, err error) {
return 0, errors.New("test error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/pgp/pgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s Signature) CanonicalValue() ([]byte, error) {
}

// Verify implements the pki.Signature interface
func (s Signature) Verify(r io.Reader, k interface{}, opts ...sigsig.VerifyOption) error {
func (s Signature) Verify(r io.Reader, k interface{}, _ ...sigsig.VerifyOption) error {
if len(s.signature) == 0 {
return fmt.Errorf("PGP signature has not been initialized")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/pgp/pgp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestReadSignature(t *testing.T) {
type BadReader struct {
}

func (br BadReader) Read(p []byte) (n int, err error) {
func (br BadReader) Read(_ []byte) (n int, err error) {
return 0, errors.New("test error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/pkcs7/pkcs7.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (s Signature) CanonicalValue() ([]byte, error) {
}

// Verify implements the pki.Signature interface
func (s Signature) Verify(r io.Reader, k interface{}, opts ...sigsig.VerifyOption) error {
func (s Signature) Verify(r io.Reader, _ interface{}, _ ...sigsig.VerifyOption) error {
if len(*s.raw) == 0 {
return fmt.Errorf("PKCS7 signature has not been initialized")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s Signature) CanonicalValue() ([]byte, error) {
}

// Verify implements the pki.Signature interface
func (s Signature) Verify(r io.Reader, k interface{}, opts ...sigsig.VerifyOption) error {
func (s Signature) Verify(r io.Reader, k interface{}, _ ...sigsig.VerifyOption) error {
if s.signature == nil {
return fmt.Errorf("ssh signature has not been initialized")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/pki/tuf/tuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s Signature) CanonicalValue() ([]byte, error) {
}

// Verify implements the pki.Signature interface
func (s Signature) Verify(_ io.Reader, k interface{}, opts ...sigsig.VerifyOption) error {
func (s Signature) Verify(_ io.Reader, k interface{}, _ ...sigsig.VerifyOption) error {
key, ok := k.(*PublicKey)
if !ok {
return fmt.Errorf("invalid public key type for: %v", k)
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/alpine/alpine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/cose/cose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/cose/v0.0.1/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (v *V001Entry) Unmarshal(pe models.ProposedEntry) error {
return v.validate()
}

func (v *V001Entry) Canonicalize(ctx context.Context) ([]byte, error) {
func (v *V001Entry) Canonicalize(_ context.Context) ([]byte, error) {
if v.keyObj == nil {
return nil, errors.New("cannot canonicalze empty key")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/hashedrekord/hashedrekord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/types/hashedrekord/v0.0.1/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (v *V001Entry) Unmarshal(pe models.ProposedEntry) error {
return err
}

func (v *V001Entry) Canonicalize(ctx context.Context) ([]byte, error) {
func (v *V001Entry) Canonicalize(_ context.Context) ([]byte, error) {
sigObj, keyObj, err := v.validate()
if err != nil {
return nil, types.ValidationError(err)
Expand Down Expand Up @@ -189,7 +189,7 @@ func (v *V001Entry) validate() (pki.Signature, pki.PublicKey, error) {
return sigObj, keyObj, nil
}

func (v V001Entry) CreateFromArtifactProperties(ctx context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
func (v V001Entry) CreateFromArtifactProperties(_ context.Context, props types.ArtifactProperties) (models.ProposedEntry, error) {
returnVal := models.Hashedrekord{}
re := V001Entry{}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/intoto/intoto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/intoto/v0.0.1/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (v *V001Entry) Unmarshal(pe models.ProposedEntry) error {
return v.validate()
}

func (v *V001Entry) Canonicalize(ctx context.Context) ([]byte, error) {
func (v *V001Entry) Canonicalize(_ context.Context) ([]byte, error) {
if v.keyObj == nil {
return nil, errors.New("cannot canonicalize empty key")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/intoto/v0.0.2/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (v *V002Entry) Unmarshal(pe models.ProposedEntry) error {
return nil
}

func (v *V002Entry) Canonicalize(ctx context.Context) ([]byte, error) {
func (v *V002Entry) Canonicalize(_ context.Context) ([]byte, error) {
if err := v.IntotoObj.Validate(strfmt.Default); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/jar/jar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/jar/v0.0.1/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (v *V001Entry) Unmarshal(pe models.ProposedEntry) error {
return v.validate()
}

func (v *V001Entry) fetchExternalEntities(ctx context.Context) (*pkcs7.PublicKey, *pkcs7.Signature, error) {
func (v *V001Entry) fetchExternalEntities(_ context.Context) (*pkcs7.PublicKey, *pkcs7.Signature, error) {
if err := v.validate(); err != nil {
return nil, nil, types.ValidationError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/rekord/rekord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/rfc3161/rfc3161_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/types/rfc3161/v0.0.1/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (v *V001Entry) Unmarshal(pe models.ProposedEntry) error {
return nil
}

func (v *V001Entry) Canonicalize(ctx context.Context) ([]byte, error) {
func (v *V001Entry) Canonicalize(_ context.Context) ([]byte, error) {
if v.tsrContent == nil {
return nil, errors.New("tsr content must be set before canonicalizing")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/rpm/rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (u UnmarshalFailsTester) NewEntry() types.EntryImpl {
return &UnmarshalFailsTester{}
}

func (u UnmarshalFailsTester) Unmarshal(pe models.ProposedEntry) error {
func (u UnmarshalFailsTester) Unmarshal(_ models.ProposedEntry) error {
return errors.New("error")
}

Expand Down
Loading

0 comments on commit 7359299

Please sign in to comment.