Merge pull request #1537 from codysoyland/1515-metalinter-nakedret

Fix linter issues: nakedret
This commit is contained in:
Cody Soyland 2018-07-19 08:57:13 -05:00 • committed by GitHub
commit 18a19d2f2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 36 deletions

View file

@ -121,6 +121,7 @@ gometalinter: require-gometalinter
--enable=ineffassign \
--enable=interfacer \
--enable=misspell \
--enable=nakedret \
--enable=unparam \
--exclude "^internal/.*\.pb\.go" \
--exclude "^pql/pql.peg.go" \

View file

@ -143,7 +143,7 @@ func (s *attrStore) Attrs(id uint64) (m map[string]interface{}, err error) {
// Add to cache.
s.attrCache.Set(id, m)
return
return m, nil
}
// SetAttrs sets attribute values for a given ID.

View file

@ -193,7 +193,7 @@ func (q *x) siblings(i int) (l, r *d) {
r = q.x[i+1].ch.(*d)
}
}
return
return l, r
}
// -------------------------------------------------------------------------- d
@ -415,7 +415,7 @@ func (t *tree) First() (k uint64, v *roaring.Container) {
q := &q.d[0]
k, v = q.k, q.v
}
return
return k, v
}
// Get returns the value associated with k and true if it exists. Otherwise Get
@ -466,7 +466,7 @@ func (t *tree) Last() (k uint64, v *roaring.Container) {
q := &q.d[q.c-1]
k, v = q.k, q.v
}
return
return k, v
}
// Len returns the number of items in the tree.
@ -851,7 +851,7 @@ func (e *enumerator) Close() {
// io.EOF is returned.
func (e *enumerator) Next() (k uint64, v *roaring.Container, err error) {
if err = e.err; err != nil {
return
return 0, nil, err
}
if e.ver != e.t.ver {
@ -861,12 +861,12 @@ func (e *enumerator) Next() (k uint64, v *roaring.Container, err error) {
}
if e.q == nil {
e.err, err = io.EOF, io.EOF
return
return 0, nil, err
}
if e.i >= e.q.c {
if err = e.next(); err != nil {
return
return 0, nil, err
}
}
@ -874,7 +874,7 @@ func (e *enumerator) Next() (k uint64, v *roaring.Container, err error) {
k, v = i.k, i.v
e.k, e.hit = k, true
e.next()
return
return k, v, nil
}
func (e *enumerator) next() error {
@ -899,7 +899,7 @@ func (e *enumerator) next() error {
// == io.EOF is returned.
func (e *enumerator) Prev() (k uint64, v *roaring.Container, err error) {
if err = e.err; err != nil {
return
return 0, nil, err
}
if e.ver != e.t.ver {
@ -909,19 +909,19 @@ func (e *enumerator) Prev() (k uint64, v *roaring.Container, err error) {
}
if e.q == nil {
e.err, err = io.EOF, io.EOF
return
return 0, nil, err
}
if !e.hit {
// move to previous because Seek overshoots if there's no hit
if err = e.prev(); err != nil {
return
return 0, nil, err
}
}
if e.i >= e.q.c {
if err = e.prev(); err != nil {
return
return 0, nil, err
}
}
@ -929,7 +929,7 @@ func (e *enumerator) Prev() (k uint64, v *roaring.Container, err error) {
k, v = i.k, i.v
e.k, e.hit = k, true
e.prev()
return
return k, v, err
}
func (e *enumerator) prev() error {

View file

@ -128,7 +128,7 @@ func (btc *bTreeContainers) Count() (n uint64) {
n += uint64(c.N())
_, c, err = e.Next()
}
return
return n
}
func (btc *bTreeContainers) Clone() roaring.Containers {

View file

@ -821,9 +821,9 @@ func (f *Field) allTimeViewsSortedByQuantum() (me []*view) {
}
}
}
return
return lt
})
return
return me
}
// Value reads a field value for a column.

View file

@ -1165,12 +1165,11 @@ func (f *fragment) readContiguousChecksums(a *[]FragmentBlock, blockID int) (n i
func (f *fragment) blockData(id int) (rowIDs, columnIDs []uint64) {
f.mu.Lock()
defer f.mu.Unlock()
f.storage.ForEachRange(uint64(id)*HashBlockSize*ShardWidth, (uint64(id)+1)*HashBlockSize*ShardWidth, func(i uint64) {
rowIDs = append(rowIDs, i/ShardWidth)
columnIDs = append(columnIDs, i%ShardWidth)
})
return
return rowIDs, columnIDs
}
// mergeBlock compares the block's bits and computes a diff with another set of block bits.
@ -1966,12 +1965,12 @@ func (s *fragmentSyncer) syncBlock(id int) error {
return nil
}
func madvise(b []byte, advice int) (err error) { // nolint: unparam
_, _, e1 := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice))
if e1 != 0 {
err = e1
func madvise(b []byte, advice int) error { // nolint: unparam
_, _, err := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice))
if err != 0 {
return err
}
return
return nil
}
// pairSet is a list of equal length row and column id lists.

View file

@ -302,7 +302,7 @@ type successResponse struct {
func (r *successResponse) check(err error) (statusCode int) {
if err == nil {
r.Success = true
return
return 0
}
cause := errors.Cause(err)
@ -322,7 +322,7 @@ func (r *successResponse) check(err error) (statusCode int) {
r.Success = false
r.Error = &Error{Message: cause.Error()}
return
return statusCode
}
// write sends a response to the http.ResponseWriter based on the success

View file

@ -73,13 +73,13 @@ func (c *Cache) Add(key Key, value interface{}) {
// Get looks up a key's value from the cache.
func (c *Cache) Get(key Key) (value interface{}, ok bool) {
if c.cache == nil {
return
return nil, false
}
if ele, hit := c.cache[key]; hit {
c.ll.MoveToFront(ele)
return ele.Value.(*entry).value, true
}
return
return nil, false
}
// remove removes the provided key from the cache.

View file

@ -1923,7 +1923,7 @@ func intersectionCountRunRun(a, b *Container) (n int) {
i++
}
}
return
return n
}
func intersectionCountBitmapRun(a, b *Container) (n int) {
@ -3149,17 +3149,13 @@ func xorCompare(x *xorstm) (r1 interval16, hasData bool) {
if !x.vaValid || !x.vbValid {
if x.vbValid {
x.vbValid = false
r1 = x.vb
hasData = true
return
return x.vb, true
}
if x.vaValid {
x.vaValid = false
r1 = x.va
hasData = true
return
return x.va, true
}
return
return r1, false
}
if x.va.last < x.vb.start { //va before
@ -3232,7 +3228,7 @@ func xorCompare(x *xorstm) (r1 interval16, hasData bool) {
}
}
}
return
return r1, hasData
}
//stm is state machine used to "xor" iterate over runs.