Skip to content

Commit

Permalink
Remove go vet warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Juanjo Alvarez <[email protected]>
  • Loading branch information
Juanjo Alvarez committed Apr 24, 2019
1 parent 90b377c commit c510991
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 36 deletions.
6 changes: 4 additions & 2 deletions blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ func (r *blobsTable) PartitionRows(
r.filters,
r.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
hashes, err := selectors.textValues("blob_hash")
var hashes []string
hashes, err = selectors.textValues("blob_hash")
if err != nil {
return nil, err
}

if r.index != nil {
indexValues, err := r.index.Values(p)
var indexValues sql.IndexValueIter
indexValues, err = r.index.Values(p)
if err != nil {
return nil, err
}
Expand Down
6 changes: 4 additions & 2 deletions commit_blobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ func (t *commitBlobsTable) PartitionRows(
t.filters,
t.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
repos, err := selectors.textValues("repository_id")
var repos []string
repos, err = selectors.textValues("repository_id")
if err != nil {
return nil, err
}
Expand All @@ -87,7 +88,8 @@ func (t *commitBlobsTable) PartitionRows(
return noRows, nil
}

commits, err := selectors.textValues("commit_hash")
var commits []string
commits, err = selectors.textValues("commit_hash")
if err != nil {
return nil, err
}
Expand Down
9 changes: 6 additions & 3 deletions commit_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func (t *commitFilesTable) PartitionRows(
t.filters,
t.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
repos, err := selectors.textValues("repository_id")
var repos []string
repos, err = selectors.textValues("repository_id")
if err != nil {
return nil, err
}
Expand All @@ -93,12 +94,14 @@ func (t *commitFilesTable) PartitionRows(
return noRows, nil
}

hashes, err := selectors.textValues("commit_hash")
var hashes []string
hashes, err = selectors.textValues("commit_hash")
if err != nil {
return nil, err
}

paths, err := selectors.textValues("file_path")
var paths []string
paths, err = selectors.textValues("file_path")
if err != nil {
return nil, err
}
Expand Down
6 changes: 4 additions & 2 deletions commit_trees.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (t *commitTreesTable) PartitionRows(
t.filters,
t.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
repos, err := selectors.textValues("repository_id")
var repos []string
repos, err = selectors.textValues("repository_id")
if err != nil {
return nil, err
}
Expand All @@ -88,7 +89,8 @@ func (t *commitTreesTable) PartitionRows(
return noRows, nil
}

hashes, err := selectors.textValues("commit_hash")
var hashes []string
hashes, err = selectors.textValues("commit_hash")
if err != nil {
return nil, err
}
Expand Down
11 changes: 7 additions & 4 deletions commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,21 @@ func (r *commitsTable) PartitionRows(
r.filters,
r.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
hashes, err := selectors.textValues("commit_hash")
var hashes []string
hashes, err = selectors.textValues("commit_hash")
if err != nil {
return nil, err
}

if r.index != nil {
indexValues, err := r.index.Values(p)
var indexValues sql.IndexValueIter
indexValues, err = r.index.Values(p)
if err != nil {
return nil, err
}

s, err := getSession(ctx)
var s *Session
s, err = getSession(ctx)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -243,7 +246,7 @@ func (i *commitIter) Next() (*object.Commit, error) {
var err error

if i.ref == nil {
if err := i.loadNextRef(); err != nil {
if err = i.loadNextRef(); err != nil {
return nil, err
}

Expand Down
18 changes: 12 additions & 6 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func (r *filesTable) PartitionRows(
r.filters,
r.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
repos, err := selectors.textValues("repository_id")
var repos []string
repos, err = selectors.textValues("repository_id")
if err != nil {
return nil, err
}
Expand All @@ -88,28 +89,33 @@ func (r *filesTable) PartitionRows(
return noRows, nil
}

treeHashes, err := selectors.textValues("tree_hash")
var treeHashes []string
treeHashes, err = selectors.textValues("tree_hash")
if err != nil {
return nil, err
}

blobHashes, err := selectors.textValues("blob_hash")
var blobHashes []string
blobHashes, err = selectors.textValues("blob_hash")
if err != nil {
return nil, err
}

filePaths, err := selectors.textValues("file_path")
var filePaths []string
filePaths, err = selectors.textValues("file_path")
if err != nil {
return nil, err
}

if r.index != nil {
values, err := r.index.Values(p)
var values sql.IndexValueIter
values, err = r.index.Values(p)
if err != nil {
return nil, err
}

session, err := getSession(ctx)
var session *Session
session, err = getSession(ctx)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ func handledFilters(
// table.
var hasOtherFields bool
expression.Inspect(f, func(e sql.Expression) bool {
if e, ok := e.(*expression.GetField); ok {
if e.Table() != tableName {
if gf, ok := e.(*expression.GetField); ok {
if gf.Table() != tableName {
hasOtherFields = true
}
}
Expand Down
8 changes: 2 additions & 6 deletions packfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"io"
"os"

errors "gopkg.in/src-d/go-errors.v1"
"gopkg.in/src-d/go-errors.v1"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
"gopkg.in/src-d/go-git.v4/utils/ioutil"

"gopkg.in/src-d/go-billy-siva.v4"
billy "gopkg.in/src-d/go-billy.v4"
"gopkg.in/src-d/go-billy.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/format/idxfile"
"gopkg.in/src-d/go-git.v4/plumbing/format/objfile"
Expand Down Expand Up @@ -244,10 +244,6 @@ func newRepoObjectDecoder(
}

packfile := packfile.NewPackfile(idx, fs, packf)
if err != nil {
_ = packf.Close()
return nil, err
}

return &repoObjectDecoder{
repo: repo.ID(),
Expand Down
16 changes: 9 additions & 7 deletions ref_commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func (t *refCommitsTable) PartitionRows(
t.filters,
t.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
repos, err := selectors.textValues("repository_id")
var repos []string
repos, err = selectors.textValues("repository_id")
if err != nil {
return nil, err
}
Expand All @@ -91,7 +92,8 @@ func (t *refCommitsTable) PartitionRows(
return noRows, nil
}

names, err := selectors.textValues("ref_name")
var names []string
names, err = selectors.textValues("ref_name")
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -290,10 +292,10 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
if i.commits == nil {
var ref *plumbing.Reference
if i.head == nil {
var err error
ref, err = i.refs.Next()
if err != nil {
if err == io.EOF {
var err_ error
ref, err_ = i.refs.Next()
if err_ != nil {
if err_ == io.EOF {
i.repo.Close()
return nil, io.EOF
}
Expand All @@ -303,7 +305,7 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
}

i.repo.Close()
return nil, err
return nil, err_
}
} else {
ref = plumbing.NewHashReference(plumbing.ReferenceName("HEAD"), i.head.Hash())
Expand Down
6 changes: 4 additions & 2 deletions references.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ func (r *referencesTable) PartitionRows(
r.filters,
r.handledColumns(),
func(selectors selectors) (sql.RowIter, error) {
hashes, err := selectors.textValues("commit_hash")
var hashes []string
hashes, err = selectors.textValues("commit_hash")
if err != nil {
return nil, err
}

names, err := selectors.textValues("ref_name")
var names []string
names, err = selectors.textValues("ref_name")
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c510991

Please sign in to comment.