mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #1534 from codysoyland/1505-metalinter-deadcode
Fix linter issues: deadcode
This commit is contained in:
commit
cceb1ebdf6
10 changed files with 37 additions and 74 deletions
|
|
@ -21,10 +21,8 @@ jobs:
|
|||
include:
|
||||
- stage: metalinter
|
||||
install:
|
||||
- make -B install-dep vendor
|
||||
- go get -u github.com/alecthomas/gometalinter
|
||||
- gometalinter --install
|
||||
script: make metalinter
|
||||
- make -B install-dep vendor install-gometalinter
|
||||
script: make gometalinter
|
||||
env:
|
||||
- GOARCH=amd64
|
||||
- stage: deploy
|
||||
|
|
|
|||
27
Makefile
27
Makefile
|
|
@ -1,4 +1,4 @@
|
|||
.PHONY: build check-clean clean cover cover-viz default docker docker-build docker-test generate generate-protoc generate-pql install install-build-deps install-dep install-protoc install-protoc-gen-gofast install-peg metalinter prerelease prerelease-upload release release-build require-dep require-protoc require-protoc-gen-gofast require-peg test
|
||||
.PHONY: build check-clean clean cover cover-viz default docker docker-build docker-test generate generate-protoc generate-pql gometalinter install install-build-deps install-dep install-gometalinter install-protoc install-protoc-gen-gofast install-peg prerelease prerelease-upload release release-build require-dep require-gometalinter require-protoc require-protoc-gen-gofast require-peg test
|
||||
|
||||
CLONE_URL=github.com/pilosa/pilosa
|
||||
VERSION := $(shell git describe --tags 2> /dev/null || echo unknown)
|
||||
|
|
@ -108,8 +108,21 @@ docker-build:
|
|||
docker-test:
|
||||
docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) golang:$(GO_VERSION) go test -tags='$(BUILD_TAGS)' $(TESTFLAGS) ./...
|
||||
|
||||
metalinter:
|
||||
gometalinter --vendor --disable-all --enable=gotype --enable=gotypex --enable=gofmt --enable=goimports --enable=interfacer --enable=misspell --enable=unparam --deadline=60s --exclude "^internal/.*\.pb\.go" ./...
|
||||
# Run gometalinter with custom flags
|
||||
gometalinter: require-gometalinter
|
||||
gometalinter --vendor --disable-all \
|
||||
--deadline=60s \
|
||||
--enable=deadcode \
|
||||
--enable=gofmt \
|
||||
--enable=goimports \
|
||||
--enable=gotype \
|
||||
--enable=gotypex \
|
||||
--enable=interfacer \
|
||||
--enable=misspell \
|
||||
--enable=unparam \
|
||||
--exclude "^internal/.*\.pb\.go" \
|
||||
--exclude "^pql/pql.peg.go" \
|
||||
./...
|
||||
|
||||
######################
|
||||
# Build dependencies #
|
||||
|
|
@ -134,6 +147,9 @@ require-protoc:
|
|||
require-peg:
|
||||
$(call require,peg)
|
||||
|
||||
require-gometalinter:
|
||||
$(call require,gometalinter)
|
||||
|
||||
install-build-deps: install-dep install-protoc-gen-gofast install-protoc install-stringer install-peg
|
||||
|
||||
install-dep:
|
||||
|
|
@ -150,3 +166,8 @@ install-protoc:
|
|||
|
||||
install-peg:
|
||||
go get github.com/pointlander/peg
|
||||
|
||||
install-gometalinter:
|
||||
go get -u github.com/alecthomas/gometalinter
|
||||
gometalinter --install
|
||||
go get github.com/remyoudompheng/go-misc/deadcode
|
||||
|
|
|
|||
6
attr.go
6
attr.go
|
|
@ -204,12 +204,6 @@ func DecodeAttrs(v []byte) (map[string]interface{}, error) {
|
|||
return decodeAttrs(pb.GetAttrs()), nil
|
||||
}
|
||||
|
||||
func newMemAttrStore() AttrStore {
|
||||
return &memAttrStore{
|
||||
store: make(map[uint64]map[string]interface{}),
|
||||
}
|
||||
}
|
||||
|
||||
// memAttrStore represents an in-memory implementation of the AttrStore interface.
|
||||
type memAttrStore struct {
|
||||
store map[uint64]map[string]interface{}
|
||||
|
|
|
|||
|
|
@ -792,9 +792,6 @@ type Hasher interface {
|
|||
Hash(key uint64, n int) int
|
||||
}
|
||||
|
||||
// newHasher returns a new instance of the default hasher.
|
||||
func newHasher() Hasher { return &jmphasher{} }
|
||||
|
||||
// jmphasher represents an implementation of jmphash. Implements Hasher.
|
||||
type jmphasher struct{}
|
||||
|
||||
|
|
|
|||
|
|
@ -372,7 +372,8 @@ func TestHasher(t *testing.T) {
|
|||
{0x0ddc0ffeebadf00d, []int{0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 15, 15, 15, 15}},
|
||||
} {
|
||||
for i, v := range tt.bucket {
|
||||
if got := newHasher().Hash(tt.key, i+1); got != v {
|
||||
hasher := &jmphasher{}
|
||||
if got := hasher.Hash(tt.key, i+1); got != v {
|
||||
t.Errorf("hash(%v,%v)=%v, want %v", tt.key, i+1, got, v)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1672,15 +1672,6 @@ type execOptions struct {
|
|||
ExcludeColumns bool
|
||||
}
|
||||
|
||||
// decodeError returns an error representation of s if s is non-blank.
|
||||
// Returns nil if s is blank.
|
||||
func decodeError(s string) error {
|
||||
if s == "" {
|
||||
return nil
|
||||
}
|
||||
return errors.New(s)
|
||||
}
|
||||
|
||||
// hasOnlySetRowAttrs returns true if calls only contains SetRowAttrs() calls.
|
||||
func hasOnlySetRowAttrs(calls []*pql.Call) bool {
|
||||
if len(calls) == 0 {
|
||||
|
|
|
|||
|
|
@ -1250,7 +1250,9 @@ func mustOpenFragment(index, field, view string, shard uint64, cacheType string)
|
|||
|
||||
f := newFragment(file.Name(), index, field, view, shard)
|
||||
f.CacheType = cacheType
|
||||
f.RowAttrStore = newMemAttrStore()
|
||||
f.RowAttrStore = &memAttrStore{
|
||||
store: make(map[uint64]map[string]interface{}),
|
||||
}
|
||||
|
||||
if err := f.Open(); err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
|
|
@ -1122,12 +1122,9 @@ func (h *Handler) handleGetVersion(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
// QueryResult types.
|
||||
const (
|
||||
queryResultTypeNil uint32 = iota
|
||||
QueryResultTypeRow
|
||||
QueryResultTypeRow uint32 = iota
|
||||
QueryResultTypePairs
|
||||
queryResultTypeValCount
|
||||
QueryResultTypeUint64
|
||||
queryResultTypeBool
|
||||
)
|
||||
|
||||
// parseUint64Slice returns a slice of uint64s from a comma-delimited string.
|
||||
|
|
@ -1149,14 +1146,6 @@ func parseUint64Slice(s string) ([]uint64, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
// errorString returns the string representation of err.
|
||||
func errorString(err error) string {
|
||||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
func (h *Handler) handlePostClusterResizeSetCoordinator(w http.ResponseWriter, r *http.Request) {
|
||||
if !validHeaderAcceptJSON(r.Header) {
|
||||
http.Error(w, "JSON only acceptable response", http.StatusNotAcceptable)
|
||||
|
|
|
|||
|
|
@ -1800,7 +1800,7 @@ type containerInfo struct {
|
|||
|
||||
// flip returns a new container containing the inverse of all
|
||||
// bits in a.
|
||||
func flip(a *Container) *Container {
|
||||
func flip(a *Container) *Container { // nolint: deadcode
|
||||
if a.isArray() {
|
||||
return flipArray(a)
|
||||
} else if a.isRun() {
|
||||
|
|
@ -3304,7 +3304,7 @@ func xorBitmapRun(a, b *Container) *Container {
|
|||
return output
|
||||
}
|
||||
|
||||
func bitmapsEqual(b, c *Bitmap) error {
|
||||
func bitmapsEqual(b, c *Bitmap) error { // nolint: deadcode
|
||||
if b.OpWriter != c.OpWriter {
|
||||
return errors.New("opWriters not equal")
|
||||
}
|
||||
|
|
@ -3336,22 +3336,6 @@ func popcount(x uint64) uint64 {
|
|||
return uint64(bits.OnesCount64(x))
|
||||
}
|
||||
|
||||
func popcountSlice(s []uint64) uint64 {
|
||||
cnt := uint64(0)
|
||||
for _, x := range s {
|
||||
cnt += popcount(x)
|
||||
}
|
||||
return cnt
|
||||
}
|
||||
|
||||
func popcountMaskSlice(s, m []uint64) uint64 {
|
||||
cnt := uint64(0)
|
||||
for i := range s {
|
||||
cnt += popcount(s[i] &^ m[i])
|
||||
}
|
||||
return cnt
|
||||
}
|
||||
|
||||
func popcountAndSlice(s, m []uint64) uint64 {
|
||||
cnt := uint64(0)
|
||||
for i := range s {
|
||||
|
|
@ -3359,19 +3343,3 @@ func popcountAndSlice(s, m []uint64) uint64 {
|
|||
}
|
||||
return cnt
|
||||
}
|
||||
|
||||
func popcountOrSlice(s, m []uint64) uint64 {
|
||||
cnt := uint64(0)
|
||||
for i := range s {
|
||||
cnt += popcount(s[i] | m[i])
|
||||
}
|
||||
return cnt
|
||||
}
|
||||
|
||||
func popcountXorSlice(s, m []uint64) uint64 {
|
||||
cnt := uint64(0)
|
||||
for i := range s {
|
||||
cnt += popcount(s[i] ^ m[i])
|
||||
}
|
||||
return cnt
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@ func mustOpenView(index, field, name string) *view {
|
|||
if err := v.open(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
v.rowAttrStore = newMemAttrStore()
|
||||
v.rowAttrStore = &memAttrStore{
|
||||
store: make(map[uint64]map[string]interface{}),
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue