diff --git a/.travis.yml b/.travis.yml index 04f234845..186c5257c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ matrix: ### run linters ### - env: MODE=lint install: - - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin v1.13 + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin v1.16.0 # install protoc - curl -L https://github.com/google/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip -o /tmp/protoc.zip - unzip /tmp/protoc.zip -d "$HOME"/protoc diff --git a/Makefile b/Makefile index ad61d6f2a..d275d54e7 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ build-dev-deps: ## Install dependencies for builds go get github.com/mattn/goveralls go get golang.org/x/tools/cover go get github.com/modocache/gover - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin v1.10.2 + curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin v1.16.0 .PHONY: lint lint: check-copyrights ## Analyze and find programs in source code diff --git a/internal/dbutil/pgutil/query.go b/internal/dbutil/pgutil/query.go index 3e1a4064e..d69fafb12 100644 --- a/internal/dbutil/pgutil/query.go +++ b/internal/dbutil/pgutil/query.go @@ -113,10 +113,6 @@ func QuerySchema(db dbschema.Queryer) (*dbschema.Schema, error) { default: return fmt.Errorf("unhandled constraint type %q", constraintType) } - - if err != nil { - return err - } } return rows.Err() }() diff --git a/pkg/certificates/certificates.go b/pkg/certificates/certificates.go index 7b3785eaa..a61ec69bf 100644 --- a/pkg/certificates/certificates.go +++ b/pkg/certificates/certificates.go @@ -302,12 +302,9 @@ func (authDB *AuthorizationDB) UserIDs() (userIDs []string, err error) { err = authDB.DB.Iterate(storage.IterateOptions{ Recurse: true, }, func(iterator storage.Iterator) error { - listItem := new(storage.ListItem) - for more := true; more; { - more = iterator.Next(listItem) - if listItem != nil { - userIDs = append(userIDs, listItem.Key.String()) - } + var listItem storage.ListItem + for iterator.Next(&listItem) { + userIDs = append(userIDs, listItem.Key.String()) } return nil }) @@ -320,19 +317,13 @@ func (authDB *AuthorizationDB) List() (auths Authorizations, err error) { Recurse: true, }, func(iterator storage.Iterator) error { var listErrs errs.Group - listItem := new(storage.ListItem) - for more := true; more; { - more = iterator.Next(listItem) - if listItem != nil { - var nextAuths Authorizations - if err := nextAuths.Unmarshal(listItem.Value); err != nil { - listErrs.Add(err) - } - auths = append(auths, nextAuths...) - } - if !more { - break + var listItem storage.ListItem + for iterator.Next(&listItem) { + var nextAuths Authorizations + if err := nextAuths.Unmarshal(listItem.Value); err != nil { + listErrs.Add(err) } + auths = append(auths, nextAuths...) } return listErrs.Err() }) diff --git a/satellite/satellitedb/certdb.go b/satellite/satellitedb/certdb.go index 07a83b397..1118c1cb2 100644 --- a/satellite/satellitedb/certdb.go +++ b/satellite/satellitedb/certdb.go @@ -32,9 +32,6 @@ func (b *certDB) SavePublicKey(ctx context.Context, nodeID storj.NodeID, publicK return Error.Wrap(errs.Combine(err, tx.Rollback())) } - if err != nil { - return Error.Wrap(errs.Combine(err, tx.Rollback())) - } _, err = tx.Create_CertRecord(ctx, dbx.CertRecord_Publickey(pubbytes), dbx.CertRecord_Id(nodeID.Bytes()), diff --git a/storage/common.go b/storage/common.go index 16215997a..2d98c864a 100644 --- a/storage/common.go +++ b/storage/common.go @@ -94,8 +94,8 @@ type IterateOptions struct { // Iterator iterates over a sequence of ListItems type Iterator interface { - // Next prepares the next list item - // returns false when you reach final item + // Next prepares the next list item. + // It returns true on success, or false if there is no next result row or an error happened while preparing it. Next(item *ListItem) bool }