mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-07 11:27:50 +00:00
Fix linter issues: gosimple
This commit is contained in:
parent
c7e29b48f9
commit
f01d850b17
18 changed files with 37 additions and 116 deletions
1
Makefile
1
Makefile
|
|
@ -116,6 +116,7 @@ gometalinter: require-gometalinter
|
|||
--enable=gochecknoinits \
|
||||
--enable=gofmt \
|
||||
--enable=goimports \
|
||||
--enable=gosimple \
|
||||
--enable=gotype \
|
||||
--enable=gotypex \
|
||||
--enable=ineffassign \
|
||||
|
|
|
|||
|
|
@ -100,10 +100,8 @@ func (s *attrStore) Open() error {
|
|||
|
||||
// Initialize database.
|
||||
if err := s.db.Update(func(tx *bolt.Tx) error {
|
||||
if _, err := tx.CreateBucketIfNotExists([]byte("attrs")); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
_, err := tx.CreateBucketIfNotExists([]byte("attrs"))
|
||||
return err
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "initializing")
|
||||
}
|
||||
|
|
@ -132,10 +130,7 @@ func (s *attrStore) Attrs(id uint64) (m map[string]interface{}, err error) {
|
|||
// Find attributes from storage.
|
||||
if err = s.db.View(func(tx *bolt.Tx) error {
|
||||
m, err = txAttrs(tx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "finding attributes")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,7 @@ Performs a consistency check on data files.
|
|||
return fmt.Errorf("path required")
|
||||
}
|
||||
checker.Paths = args
|
||||
if err := checker.Run(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return checker.Run(context.Background())
|
||||
},
|
||||
}
|
||||
return checkCmd
|
||||
|
|
|
|||
|
|
@ -37,10 +37,7 @@ func newConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command
|
|||
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
conf.Config = Server.Config
|
||||
if err := conf.Run(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return conf.Run(context.Background())
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,10 +42,7 @@ The format of the CSV file is:
|
|||
The file does not contain any headers.
|
||||
`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := Exporter.Run(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return Exporter.Run(context.Background())
|
||||
},
|
||||
}
|
||||
flags := exportCmd.Flags()
|
||||
|
|
|
|||
|
|
@ -34,10 +34,7 @@ func newGenerateConfigCommand(_ io.Reader, _, _ io.Writer) *cobra.Command {
|
|||
Long: `generate-config prints the default configuration to stdout
|
||||
`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := generateConf.Run(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return generateConf.Run(context.Background())
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,7 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM.
|
|||
`,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
Importer.Paths = args
|
||||
if err := Importer.Run(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return Importer.Run(context.Background())
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,10 +43,7 @@ Inspects a data file and provides stats.
|
|||
return fmt.Errorf("only one path allowed")
|
||||
}
|
||||
inspector.Path = args[0]
|
||||
if err := inspector.Run(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return inspector.Run(context.Background())
|
||||
},
|
||||
}
|
||||
return inspectCmd
|
||||
|
|
|
|||
|
|
@ -232,11 +232,7 @@ func (cmd *ImportCommand) bufferBits(ctx context.Context, path string) error {
|
|||
}
|
||||
|
||||
// If there are still bits in the buffer then flush them.
|
||||
if err := cmd.importBits(ctx, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return cmd.importBits(ctx, a)
|
||||
}
|
||||
|
||||
// importBits sends batches of bits to the server.
|
||||
|
|
@ -337,11 +333,7 @@ func (cmd *ImportCommand) bufferBitsK(ctx context.Context, path string) error {
|
|||
}
|
||||
|
||||
// If there are still bitKs in the buffer then flush them.
|
||||
if err := cmd.importBitsK(ctx, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return cmd.importBitsK(ctx, a)
|
||||
}
|
||||
|
||||
// importBitsK sends batches of bitKs to the server.
|
||||
|
|
@ -426,11 +418,7 @@ func (cmd *ImportCommand) bufferValues(ctx context.Context, path string) error {
|
|||
}
|
||||
|
||||
// If there are still values in the buffer then flush them.
|
||||
if err := cmd.importValues(ctx, a); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return cmd.importValues(ctx, a)
|
||||
}
|
||||
|
||||
// importValues sends batches of FieldValues to the server.
|
||||
|
|
|
|||
2
field.go
2
field.go
|
|
@ -821,7 +821,7 @@ func groupCompare(a, b string, offset int) (lt, eq bool) {
|
|||
}
|
||||
|
||||
func (f *Field) allTimeViewsSortedByQuantum() (me []*view) {
|
||||
me = make([]*view, len(f.viewMap), len(f.viewMap))
|
||||
me = make([]*view, len(f.viewMap))
|
||||
prefix := viewStandard + "_"
|
||||
offset := len(viewStandard) + 1
|
||||
i := 0
|
||||
|
|
|
|||
|
|
@ -1713,8 +1713,7 @@ func (f *fragment) rows() []uint64 {
|
|||
i, _ := f.storage.Containers.Iterator(0)
|
||||
rows := make([]uint64, 0)
|
||||
|
||||
var lastRow uint64
|
||||
lastRow = math.MaxUint64
|
||||
var lastRow uint64 = math.MaxUint64
|
||||
|
||||
// Loop over the existing containers.
|
||||
for i.Next() {
|
||||
|
|
|
|||
|
|
@ -40,11 +40,7 @@ func (h *tHolder) Reopen() error {
|
|||
h.Holder = NewHolder()
|
||||
h.Holder.Path = path
|
||||
h.Holder.Logger = logger
|
||||
if err := h.Holder.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return h.Holder.Open()
|
||||
}
|
||||
|
||||
func newHolder() *tHolder {
|
||||
|
|
|
|||
|
|
@ -441,9 +441,9 @@ func formatValue(v interface{}) string {
|
|||
case string:
|
||||
return fmt.Sprintf("%q", v)
|
||||
case []interface{}:
|
||||
return fmt.Sprintf("%s", joinInterfaceSlice(v))
|
||||
return joinInterfaceSlice(v)
|
||||
case []uint64:
|
||||
return fmt.Sprintf("%s", joinUint64Slice(v))
|
||||
return joinUint64Slice(v)
|
||||
case time.Time:
|
||||
return fmt.Sprintf("\"%s\"", v.Format(timeFormat))
|
||||
case *Condition:
|
||||
|
|
|
|||
|
|
@ -572,15 +572,11 @@ func TestIntersectBitmapRunBitmap(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
a.bitmap[i] = v
|
||||
}
|
||||
copy(a.bitmap, test.bitmap)
|
||||
b.runs = test.runs
|
||||
b.n = 4097 // ;)
|
||||
exp := make([]uint64, bitmapN)
|
||||
for i, v := range test.exp {
|
||||
exp[i] = v
|
||||
}
|
||||
copy(exp, test.exp)
|
||||
a.containerType = containerBitmap
|
||||
b.containerType = containerRun
|
||||
ret := intersectBitmapRun(a, b)
|
||||
|
|
@ -638,9 +634,7 @@ func TestIntersectBitmapRunArray(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
a.bitmap[i] = v
|
||||
}
|
||||
copy(a.bitmap, test.bitmap)
|
||||
b.runs = test.runs
|
||||
a.containerType = containerBitmap
|
||||
b.containerType = containerRun
|
||||
|
|
@ -962,9 +956,7 @@ func TestBitmapSetRange(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
c.bitmap[i] = v
|
||||
}
|
||||
copy(c.bitmap, test.bitmap)
|
||||
c.n = c.countRange(0, 65535)
|
||||
c.bitmapSetRange(test.start, test.last+1)
|
||||
if !reflect.DeepEqual(c.bitmap[:len(test.exp)], test.exp) {
|
||||
|
|
@ -994,9 +986,7 @@ func TestArrayToBitmap(t *testing.T) {
|
|||
|
||||
for i, test := range tests {
|
||||
exp := make([]uint64, bitmapN)
|
||||
for i, v := range test.exp {
|
||||
exp[i] = v
|
||||
}
|
||||
copy(exp, test.exp)
|
||||
|
||||
a.array = test.array
|
||||
a.n = len(test.array)
|
||||
|
|
@ -1084,7 +1074,7 @@ func TestRunToBitmap(t *testing.T) {
|
|||
}
|
||||
|
||||
func getFullBitmap() []uint64 {
|
||||
x := make([]uint64, 1024, 1024)
|
||||
x := make([]uint64, 1024)
|
||||
for i := range x {
|
||||
x[i] = uint64(0xFFFFFFFFFFFFFFFF)
|
||||
}
|
||||
|
|
@ -1264,9 +1254,7 @@ func TestBitmapZeroRange(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
c.bitmap[i] = v
|
||||
}
|
||||
copy(c.bitmap, test.bitmap)
|
||||
c.n = c.countRange(0, 65535)
|
||||
c.bitmapZeroRange(test.start, test.last+1)
|
||||
if !reflect.DeepEqual(c.bitmap[:len(test.exp)], test.exp) {
|
||||
|
|
@ -1299,9 +1287,7 @@ func TestUnionBitmapRun(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
a.bitmap[i] = v
|
||||
}
|
||||
copy(a.bitmap, test.bitmap)
|
||||
a.n = a.bitmapCountRange(0, 65535)
|
||||
b.runs = test.runs
|
||||
b.n = b.runCountRange(0, 65535)
|
||||
|
|
@ -1346,9 +1332,7 @@ func TestBitmapCountRuns(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
for j, v := range test.bitmap {
|
||||
c.bitmap[j] = v
|
||||
}
|
||||
copy(c.bitmap, test.bitmap)
|
||||
|
||||
ret := c.bitmapCountRuns()
|
||||
if ret != test.exp {
|
||||
|
|
@ -1504,12 +1488,8 @@ func TestDifferenceRunArray(t *testing.T) {
|
|||
}
|
||||
}
|
||||
func MakeBitmap(start []uint64) []uint64 {
|
||||
|
||||
b := make([]uint64, bitmapN)
|
||||
for i, v := range start {
|
||||
b[i] = v
|
||||
|
||||
}
|
||||
copy(b, start)
|
||||
return b
|
||||
}
|
||||
func MakeLastBitSet() []uint64 {
|
||||
|
|
@ -1571,9 +1551,7 @@ func TestDifferenceRunBitmap(t *testing.T) {
|
|||
for i, test := range tests {
|
||||
a.runs = test.runs
|
||||
a.n = a.runCountRange(0, 65536)
|
||||
for i, v := range test.bitmap {
|
||||
b.bitmap[i] = v
|
||||
}
|
||||
copy(b.bitmap, test.bitmap)
|
||||
b.n = b.bitmapCountRange(0, 65536)
|
||||
ret := differenceRunBitmap(a, b)
|
||||
if !reflect.DeepEqual(ret.runs, test.exp) {
|
||||
|
|
@ -1652,9 +1630,7 @@ func TestDifferenceBitmapRun(t *testing.T) {
|
|||
},
|
||||
}
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
a.bitmap[i] = v
|
||||
}
|
||||
copy(a.bitmap, test.bitmap)
|
||||
a.n = a.bitmapCountRange(0, 65536)
|
||||
b.runs = test.runs
|
||||
b.n = b.runCountRange(0, 65536)
|
||||
|
|
@ -2078,9 +2054,7 @@ func TestBitmapXorRange(t *testing.T) {
|
|||
}
|
||||
|
||||
for i, test := range tests {
|
||||
for i, v := range test.bitmap {
|
||||
c.bitmap[i] = v
|
||||
}
|
||||
copy(c.bitmap, test.bitmap)
|
||||
c.n = c.countRange(0, 65535)
|
||||
c.bitmapXorRange(test.start, test.last+1)
|
||||
if !reflect.DeepEqual(c.bitmap[:len(test.exp)], test.exp) {
|
||||
|
|
@ -2595,9 +2569,7 @@ func TestIntersectArrayBitmap(t *testing.T) {
|
|||
for i, test := range tests {
|
||||
a.array = test.array
|
||||
a.containerType = containerArray
|
||||
for i, bmval := range test.bitmap {
|
||||
b.bitmap[i] = bmval
|
||||
}
|
||||
copy(b.bitmap, test.bitmap)
|
||||
b.containerType = containerBitmap
|
||||
ret := intersectArrayBitmap(a, b).array
|
||||
if len(ret) == 0 && len(test.exp) == 0 {
|
||||
|
|
|
|||
|
|
@ -65,11 +65,7 @@ func (h *Holder) Reopen() error {
|
|||
h.Holder.Path = path
|
||||
h.Holder.Logger = logger
|
||||
h.Holder.NewAttrStore = boltdb.NewAttrStore
|
||||
if err := h.Holder.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return h.Holder.Open()
|
||||
}
|
||||
|
||||
// MustCreateIndexIfNotExists returns a given index. Panic on error.
|
||||
|
|
|
|||
|
|
@ -120,10 +120,7 @@ func (m *Command) Reopen() error {
|
|||
m.Command.Config = config
|
||||
|
||||
// Run new program.
|
||||
if err := m.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return m.Start()
|
||||
}
|
||||
|
||||
// URL returns the base URL string for accessing the running program.
|
||||
|
|
|
|||
|
|
@ -923,10 +923,8 @@ func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset in
|
|||
|
||||
// Open initializes the reader.
|
||||
func (r *translateFileReader) Open() (err error) {
|
||||
if r.file, err = os.Open(r.store.Path); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
r.file, err = os.Open(r.store.Path)
|
||||
return err
|
||||
}
|
||||
|
||||
// Close closes the underlying file reader.
|
||||
|
|
|
|||
|
|
@ -568,10 +568,7 @@ func (s *TranslateFile) Reopen() error {
|
|||
s.lock.Unlock()
|
||||
s.Path = prev.Path
|
||||
s.PrimaryTranslateStore = prev.PrimaryTranslateStore
|
||||
if err := s.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return s.Open()
|
||||
}
|
||||
|
||||
// retryFor executes fn every 100ms until d time passes or until fn return nil.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue