Skip to content

Commit e5f16a0

Browse files
authored
Remove go vet warnings (#806)
Remove go vet warnings
2 parents 5597e48 + 159bf37 commit e5f16a0

10 files changed

+54
-36
lines changed

blobs.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,15 @@ func (r *blobsTable) PartitionRows(
106106
r.filters,
107107
r.handledColumns(),
108108
func(selectors selectors) (sql.RowIter, error) {
109-
hashes, err := selectors.textValues("blob_hash")
109+
var hashes []string
110+
hashes, err = selectors.textValues("blob_hash")
110111
if err != nil {
111112
return nil, err
112113
}
113114

114115
if r.index != nil {
115-
indexValues, err := r.index.Values(p)
116+
var indexValues sql.IndexValueIter
117+
indexValues, err = r.index.Values(p)
116118
if err != nil {
117119
return nil, err
118120
}

commit_blobs.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ func (t *commitBlobsTable) PartitionRows(
7878
t.filters,
7979
t.handledColumns(),
8080
func(selectors selectors) (sql.RowIter, error) {
81-
repos, err := selectors.textValues("repository_id")
81+
var repos []string
82+
repos, err = selectors.textValues("repository_id")
8283
if err != nil {
8384
return nil, err
8485
}
@@ -87,7 +88,8 @@ func (t *commitBlobsTable) PartitionRows(
8788
return noRows, nil
8889
}
8990

90-
commits, err := selectors.textValues("commit_hash")
91+
var commits []string
92+
commits, err = selectors.textValues("commit_hash")
9193
if err != nil {
9294
return nil, err
9395
}

commit_files.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func (t *commitFilesTable) PartitionRows(
8484
t.filters,
8585
t.handledColumns(),
8686
func(selectors selectors) (sql.RowIter, error) {
87-
repos, err := selectors.textValues("repository_id")
87+
var repos []string
88+
repos, err = selectors.textValues("repository_id")
8889
if err != nil {
8990
return nil, err
9091
}
@@ -93,12 +94,14 @@ func (t *commitFilesTable) PartitionRows(
9394
return noRows, nil
9495
}
9596

96-
hashes, err := selectors.textValues("commit_hash")
97+
var hashes []string
98+
hashes, err = selectors.textValues("commit_hash")
9799
if err != nil {
98100
return nil, err
99101
}
100102

101-
paths, err := selectors.textValues("file_path")
103+
var paths []string
104+
paths, err = selectors.textValues("file_path")
102105
if err != nil {
103106
return nil, err
104107
}

commit_trees.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func (t *commitTreesTable) PartitionRows(
7979
t.filters,
8080
t.handledColumns(),
8181
func(selectors selectors) (sql.RowIter, error) {
82-
repos, err := selectors.textValues("repository_id")
82+
var repos []string
83+
repos, err = selectors.textValues("repository_id")
8384
if err != nil {
8485
return nil, err
8586
}
@@ -88,7 +89,8 @@ func (t *commitTreesTable) PartitionRows(
8889
return noRows, nil
8990
}
9091

91-
hashes, err := selectors.textValues("commit_hash")
92+
var hashes []string
93+
hashes, err = selectors.textValues("commit_hash")
9294
if err != nil {
9395
return nil, err
9496
}

commits.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,21 @@ func (r *commitsTable) PartitionRows(
9090
r.filters,
9191
r.handledColumns(),
9292
func(selectors selectors) (sql.RowIter, error) {
93-
hashes, err := selectors.textValues("commit_hash")
93+
var hashes []string
94+
hashes, err = selectors.textValues("commit_hash")
9495
if err != nil {
9596
return nil, err
9697
}
9798

9899
if r.index != nil {
99-
indexValues, err := r.index.Values(p)
100+
var indexValues sql.IndexValueIter
101+
indexValues, err = r.index.Values(p)
100102
if err != nil {
101103
return nil, err
102104
}
103105

104-
s, err := getSession(ctx)
106+
var s *Session
107+
s, err = getSession(ctx)
105108
if err != nil {
106109
return nil, err
107110
}
@@ -243,7 +246,7 @@ func (i *commitIter) Next() (*object.Commit, error) {
243246
var err error
244247

245248
if i.ref == nil {
246-
if err := i.loadNextRef(); err != nil {
249+
if err = i.loadNextRef(); err != nil {
247250
return nil, err
248251
}
249252

files.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ func (r *filesTable) PartitionRows(
7979
r.filters,
8080
r.handledColumns(),
8181
func(selectors selectors) (sql.RowIter, error) {
82-
repos, err := selectors.textValues("repository_id")
82+
var repos []string
83+
repos, err = selectors.textValues("repository_id")
8384
if err != nil {
8485
return nil, err
8586
}
@@ -88,28 +89,33 @@ func (r *filesTable) PartitionRows(
8889
return noRows, nil
8990
}
9091

91-
treeHashes, err := selectors.textValues("tree_hash")
92+
var treeHashes []string
93+
treeHashes, err = selectors.textValues("tree_hash")
9294
if err != nil {
9395
return nil, err
9496
}
9597

96-
blobHashes, err := selectors.textValues("blob_hash")
98+
var blobHashes []string
99+
blobHashes, err = selectors.textValues("blob_hash")
97100
if err != nil {
98101
return nil, err
99102
}
100103

101-
filePaths, err := selectors.textValues("file_path")
104+
var filePaths []string
105+
filePaths, err = selectors.textValues("file_path")
102106
if err != nil {
103107
return nil, err
104108
}
105109

106110
if r.index != nil {
107-
values, err := r.index.Values(p)
111+
var values sql.IndexValueIter
112+
values, err = r.index.Values(p)
108113
if err != nil {
109114
return nil, err
110115
}
111116

112-
session, err := getSession(ctx)
117+
var session *Session
118+
session, err = getSession(ctx)
113119
if err != nil {
114120
return nil, err
115121
}

filters.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ func handledFilters(
171171
// table.
172172
var hasOtherFields bool
173173
expression.Inspect(f, func(e sql.Expression) bool {
174-
if e, ok := e.(*expression.GetField); ok {
175-
if e.Table() != tableName {
174+
if gf, ok := e.(*expression.GetField); ok {
175+
if gf.Table() != tableName {
176176
hasOtherFields = true
177177
}
178178
}

packfiles.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import (
44
"io"
55
"os"
66

7-
errors "gopkg.in/src-d/go-errors.v1"
7+
"gopkg.in/src-d/go-errors.v1"
88
"gopkg.in/src-d/go-git.v4/plumbing/object"
99
"gopkg.in/src-d/go-git.v4/plumbing/storer"
1010
"gopkg.in/src-d/go-git.v4/storage/filesystem"
1111
"gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
1212
"gopkg.in/src-d/go-git.v4/utils/ioutil"
1313

1414
"gopkg.in/src-d/go-billy-siva.v4"
15-
billy "gopkg.in/src-d/go-billy.v4"
15+
"gopkg.in/src-d/go-billy.v4"
1616
"gopkg.in/src-d/go-git.v4/plumbing"
1717
"gopkg.in/src-d/go-git.v4/plumbing/format/idxfile"
1818
"gopkg.in/src-d/go-git.v4/plumbing/format/objfile"
@@ -244,10 +244,6 @@ func newRepoObjectDecoder(
244244
}
245245

246246
packfile := packfile.NewPackfile(idx, fs, packf)
247-
if err != nil {
248-
_ = packf.Close()
249-
return nil, err
250-
}
251247

252248
return &repoObjectDecoder{
253249
repo: repo.ID(),

ref_commits.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ func (t *refCommitsTable) PartitionRows(
8282
t.filters,
8383
t.handledColumns(),
8484
func(selectors selectors) (sql.RowIter, error) {
85-
repos, err := selectors.textValues("repository_id")
85+
var repos []string
86+
repos, err = selectors.textValues("repository_id")
8687
if err != nil {
8788
return nil, err
8889
}
@@ -91,7 +92,8 @@ func (t *refCommitsTable) PartitionRows(
9192
return noRows, nil
9293
}
9394

94-
names, err := selectors.textValues("ref_name")
95+
var names []string
96+
names, err = selectors.textValues("ref_name")
9597
if err != nil {
9698
return nil, err
9799
}
@@ -290,10 +292,10 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
290292
if i.commits == nil {
291293
var ref *plumbing.Reference
292294
if i.head == nil {
293-
var err error
294-
ref, err = i.refs.Next()
295-
if err != nil {
296-
if err == io.EOF {
295+
var err_ error
296+
ref, err_ = i.refs.Next()
297+
if err_ != nil {
298+
if err_ == io.EOF {
297299
i.repo.Close()
298300
return nil, io.EOF
299301
}
@@ -303,7 +305,7 @@ func (i *refCommitsRowIter) next() (sql.Row, error) {
303305
}
304306

305307
i.repo.Close()
306-
return nil, err
308+
return nil, err_
307309
}
308310
} else {
309311
ref = plumbing.NewHashReference(plumbing.ReferenceName("HEAD"), i.head.Hash())

references.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ func (r *referencesTable) PartitionRows(
8484
r.filters,
8585
r.handledColumns(),
8686
func(selectors selectors) (sql.RowIter, error) {
87-
hashes, err := selectors.textValues("commit_hash")
87+
var hashes []string
88+
hashes, err = selectors.textValues("commit_hash")
8889
if err != nil {
8990
return nil, err
9091
}
9192

92-
names, err := selectors.textValues("ref_name")
93+
var names []string
94+
names, err = selectors.textValues("ref_name")
9395
if err != nil {
9496
return nil, err
9597
}

0 commit comments

Comments
 (0)