mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-22 02:51:21 -05:00
no functional changes, improving code quality (#2410)
fix misspellings; fix code that was not gofmt'd - plus take advantage of gofmt -s too; couple of unreachable golint reported fixes; reference go report card results and tests
This commit is contained in:
@@ -34,9 +34,9 @@ func createTestData(s *testSuite, buildAsMap bool) []types.Value {
|
||||
s.header = []string{"a", "b", "c"}
|
||||
structName := "SomeStruct"
|
||||
s.payload = [][]string{
|
||||
[]string{"4", "10", "255"},
|
||||
[]string{"5", "7", "100"},
|
||||
[]string{"512", "12", "55"},
|
||||
{"4", "10", "255"},
|
||||
{"5", "7", "100"},
|
||||
{"512", "12", "55"},
|
||||
}
|
||||
|
||||
sliceLen := len(s.payload)
|
||||
|
||||
+130
-130
@@ -24,16 +24,16 @@ func TestSchemaDetection(t *testing.T) {
|
||||
}
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"foo", "1", "5"},
|
||||
[]string{"bar", "0", "10"},
|
||||
[]string{"true", "1", "23"},
|
||||
[]string{"1", "1", "60"},
|
||||
[]string{"1.1", "false", "75"},
|
||||
{"foo", "1", "5"},
|
||||
{"bar", "0", "10"},
|
||||
{"true", "1", "23"},
|
||||
{"1", "1", "60"},
|
||||
{"1.1", "false", "75"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{types.StringKind},
|
||||
KindSlice{types.BoolKind, types.StringKind},
|
||||
KindSlice{
|
||||
{types.StringKind},
|
||||
{types.BoolKind, types.StringKind},
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind,
|
||||
},
|
||||
@@ -41,61 +41,61 @@ func TestSchemaDetection(t *testing.T) {
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"foo"},
|
||||
[]string{"bar"},
|
||||
[]string{"true"},
|
||||
[]string{"1"},
|
||||
[]string{"1.1"},
|
||||
{"foo"},
|
||||
{"bar"},
|
||||
{"true"},
|
||||
{"1"},
|
||||
{"1.1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{types.StringKind},
|
||||
{types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"true"},
|
||||
[]string{"1"},
|
||||
[]string{"1.1"},
|
||||
{"true"},
|
||||
{"1"},
|
||||
{"1.1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{types.StringKind},
|
||||
{types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"true"},
|
||||
[]string{"false"},
|
||||
[]string{"True"},
|
||||
[]string{"False"},
|
||||
[]string{"TRUE"},
|
||||
[]string{"FALSE"},
|
||||
[]string{"1"},
|
||||
[]string{"0"},
|
||||
{"true"},
|
||||
{"false"},
|
||||
{"True"},
|
||||
{"False"},
|
||||
{"TRUE"},
|
||||
{"FALSE"},
|
||||
{"1"},
|
||||
{"0"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{types.BoolKind, types.StringKind},
|
||||
{types.BoolKind, types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"1.1"},
|
||||
{"1"},
|
||||
{"1.1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"1.1"},
|
||||
[]string{"4.940656458412465441765687928682213723651e-50"},
|
||||
[]string{"-4.940656458412465441765687928682213723651e-50"},
|
||||
{"1"},
|
||||
{"1.1"},
|
||||
{"4.940656458412465441765687928682213723651e-50"},
|
||||
{"-4.940656458412465441765687928682213723651e-50"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
@@ -103,36 +103,36 @@ func TestSchemaDetection(t *testing.T) {
|
||||
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"1.1"},
|
||||
[]string{"1.797693134862315708145274237317043567981e+102"},
|
||||
[]string{"-1.797693134862315708145274237317043567981e+102"},
|
||||
{"1"},
|
||||
{"1.1"},
|
||||
{"1.797693134862315708145274237317043567981e+102"},
|
||||
{"-1.797693134862315708145274237317043567981e+102"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"1.1"},
|
||||
[]string{"1.797693134862315708145274237317043567981e+309"},
|
||||
[]string{"-1.797693134862315708145274237317043567981e+309"},
|
||||
{"1"},
|
||||
{"1.1"},
|
||||
{"1.797693134862315708145274237317043567981e+309"},
|
||||
{"-1.797693134862315708145274237317043567981e+309"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"0"},
|
||||
{"1"},
|
||||
{"0"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.BoolKind,
|
||||
types.StringKind},
|
||||
@@ -140,123 +140,123 @@ func TestSchemaDetection(t *testing.T) {
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"0"},
|
||||
[]string{"-0"},
|
||||
{"0"},
|
||||
{"-0"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"280"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"280"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"-180"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"-180"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"33000"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"33000"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"-44000"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"-44000"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"2547483648"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"2547483648"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{"1"},
|
||||
[]string{"-4347483648"},
|
||||
[]string{"0"},
|
||||
[]string{"-1"},
|
||||
{"1"},
|
||||
{"-4347483648"},
|
||||
{"0"},
|
||||
{"-1"},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{fmt.Sprintf("%d", uint64(1<<63))},
|
||||
[]string{fmt.Sprintf("%d", uint64(1<<63)+1)},
|
||||
{fmt.Sprintf("%d", uint64(1<<63))},
|
||||
{fmt.Sprintf("%d", uint64(1<<63)+1)},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
)
|
||||
test(
|
||||
[][]string{
|
||||
[]string{fmt.Sprintf("%d", uint64(1<<32))},
|
||||
[]string{fmt.Sprintf("%d", uint64(1<<32)+1)},
|
||||
{fmt.Sprintf("%d", uint64(1<<32))},
|
||||
{fmt.Sprintf("%d", uint64(1<<32)+1)},
|
||||
},
|
||||
[]KindSlice{
|
||||
KindSlice{
|
||||
{
|
||||
types.NumberKind,
|
||||
types.StringKind},
|
||||
},
|
||||
@@ -274,37 +274,37 @@ func TestCombinationsWithLength(t *testing.T) {
|
||||
assert.Equal(expect, combinations)
|
||||
}
|
||||
test([]int{0}, 1, [][]int{
|
||||
[]int{0},
|
||||
{0},
|
||||
})
|
||||
test([]int{1}, 1, [][]int{
|
||||
[]int{1},
|
||||
{1},
|
||||
})
|
||||
test([]int{0, 1}, 1, [][]int{
|
||||
[]int{0},
|
||||
[]int{1},
|
||||
{0},
|
||||
{1},
|
||||
})
|
||||
test([]int{0, 1}, 2, [][]int{
|
||||
[]int{0, 1},
|
||||
{0, 1},
|
||||
})
|
||||
test([]int{70, 80, 90, 100}, 1, [][]int{
|
||||
[]int{70},
|
||||
[]int{80},
|
||||
[]int{90},
|
||||
[]int{100},
|
||||
{70},
|
||||
{80},
|
||||
{90},
|
||||
{100},
|
||||
})
|
||||
test([]int{70, 80, 90, 100}, 2, [][]int{
|
||||
[]int{70, 80},
|
||||
[]int{70, 90},
|
||||
[]int{70, 100},
|
||||
[]int{80, 90},
|
||||
[]int{80, 100},
|
||||
[]int{90, 100},
|
||||
{70, 80},
|
||||
{70, 90},
|
||||
{70, 100},
|
||||
{80, 90},
|
||||
{80, 100},
|
||||
{90, 100},
|
||||
})
|
||||
test([]int{70, 80, 90, 100}, 3, [][]int{
|
||||
[]int{70, 80, 90},
|
||||
[]int{70, 80, 100},
|
||||
[]int{70, 90, 100},
|
||||
[]int{80, 90, 100},
|
||||
{70, 80, 90},
|
||||
{70, 80, 100},
|
||||
{70, 90, 100},
|
||||
{80, 90, 100},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -319,33 +319,33 @@ func TestCombinationsWithLengthFromTo(t *testing.T) {
|
||||
assert.Equal(expect, combinations)
|
||||
}
|
||||
test([]int{0}, 1, 1, [][]int{
|
||||
[]int{0},
|
||||
{0},
|
||||
})
|
||||
test([]int{1}, 1, 1, [][]int{
|
||||
[]int{1},
|
||||
{1},
|
||||
})
|
||||
test([]int{0, 1}, 1, 2, [][]int{
|
||||
[]int{0},
|
||||
[]int{1},
|
||||
[]int{0, 1},
|
||||
{0},
|
||||
{1},
|
||||
{0, 1},
|
||||
})
|
||||
test([]int{0, 1}, 2, 2, [][]int{
|
||||
[]int{0, 1},
|
||||
{0, 1},
|
||||
})
|
||||
test([]int{70, 80, 90, 100}, 1, 3, [][]int{
|
||||
[]int{70},
|
||||
[]int{80},
|
||||
[]int{90},
|
||||
[]int{100},
|
||||
[]int{70, 80},
|
||||
[]int{70, 90},
|
||||
[]int{70, 100},
|
||||
[]int{80, 90},
|
||||
[]int{80, 100},
|
||||
[]int{90, 100},
|
||||
[]int{70, 80, 90},
|
||||
[]int{70, 80, 100},
|
||||
[]int{70, 90, 100},
|
||||
[]int{80, 90, 100},
|
||||
{70},
|
||||
{80},
|
||||
{90},
|
||||
{100},
|
||||
{70, 80},
|
||||
{70, 90},
|
||||
{70, 100},
|
||||
{80, 90},
|
||||
{80, 100},
|
||||
{90, 100},
|
||||
{70, 80, 90},
|
||||
{70, 80, 100},
|
||||
{70, 90, 100},
|
||||
{80, 90, 100},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ func TestWriteValue(t *testing.T) {
|
||||
assert.Equal(http.StatusOK, w.Code, string(w.Body.Bytes()))
|
||||
|
||||
whash := wval.Hash()
|
||||
hints := map[hash.Hash]struct{}{whash: struct{}{}}
|
||||
hints := map[hash.Hash]struct{}{whash: {}}
|
||||
rdr := buildGetRefsRequestBody(hints)
|
||||
r, _ = newRequest("POST", dbName+constants.GetRefsPath, rdr)
|
||||
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
@@ -30,23 +30,23 @@ func TestQueryScanner(t *testing.T) {
|
||||
s := NewQueryScanner(`9 (99.9) -9 0x7F "99.9" and or http://localhost:8000/cli-tour::yo <= >= < > = _`)
|
||||
|
||||
scannerResults := []scannerResult{
|
||||
scannerResult{tok: scanner.Int, text: "9"},
|
||||
scannerResult{tok: int('('), text: "("},
|
||||
scannerResult{tok: scanner.Float, text: "99.9"},
|
||||
scannerResult{tok: int(')'), text: ")"},
|
||||
scannerResult{tok: '-', text: "-"},
|
||||
scannerResult{tok: scanner.Int, text: "9"},
|
||||
scannerResult{tok: scanner.Int, text: "0x7F"},
|
||||
scannerResult{tok: scanner.String, text: `"99.9"`},
|
||||
scannerResult{tok: scanner.Ident, text: "and"},
|
||||
scannerResult{tok: scanner.Ident, text: "or"},
|
||||
scannerResult{tok: scanner.Ident, text: "http://localhost:8000/cli-tour::yo"},
|
||||
scannerResult{tok: scanner.Ident, text: "<="},
|
||||
scannerResult{tok: scanner.Ident, text: ">="},
|
||||
scannerResult{tok: scanner.Ident, text: "<"},
|
||||
scannerResult{tok: scanner.Ident, text: ">"},
|
||||
scannerResult{tok: int('='), text: "="},
|
||||
scannerResult{tok: int('_'), text: "_"},
|
||||
{tok: scanner.Int, text: "9"},
|
||||
{tok: int('('), text: "("},
|
||||
{tok: scanner.Float, text: "99.9"},
|
||||
{tok: int(')'), text: ")"},
|
||||
{tok: '-', text: "-"},
|
||||
{tok: scanner.Int, text: "9"},
|
||||
{tok: scanner.Int, text: "0x7F"},
|
||||
{tok: scanner.String, text: `"99.9"`},
|
||||
{tok: scanner.Ident, text: "and"},
|
||||
{tok: scanner.Ident, text: "or"},
|
||||
{tok: scanner.Ident, text: "http://localhost:8000/cli-tour::yo"},
|
||||
{tok: scanner.Ident, text: "<="},
|
||||
{tok: scanner.Ident, text: ">="},
|
||||
{tok: scanner.Ident, text: "<"},
|
||||
{tok: scanner.Ident, text: ">"},
|
||||
{tok: int('='), text: "="},
|
||||
{tok: int('_'), text: "_"},
|
||||
}
|
||||
|
||||
for _, sr := range scannerResults {
|
||||
@@ -63,10 +63,10 @@ func TestPeek(t *testing.T) {
|
||||
|
||||
s := NewQueryScanner(`_ < "one"`)
|
||||
scannerResults := []scannerResult{
|
||||
scannerResult{tok: int('_'), text: "_"},
|
||||
scannerResult{tok: scanner.Ident, text: "<"},
|
||||
scannerResult{tok: scanner.String, text: `"one"`},
|
||||
scannerResult{tok: scanner.EOF, text: ""},
|
||||
{tok: int('_'), text: "_"},
|
||||
{tok: scanner.Ident, text: "<"},
|
||||
{tok: scanner.String, text: `"one"`},
|
||||
{tok: scanner.EOF, text: ""},
|
||||
}
|
||||
|
||||
for _, sr := range scannerResults {
|
||||
@@ -86,17 +86,17 @@ func TestParsing(t *testing.T) {
|
||||
re4 := compExpr{"index1", lt, types.Number(-2030)}
|
||||
|
||||
queries := []parseResult{
|
||||
parseResult{`index1 = 2015`, re1},
|
||||
parseResult{`(index1 = 2015 )`, re1},
|
||||
parseResult{`(((index1 = 2015 ) ))`, re1},
|
||||
parseResult{`index1 = 2015 or index1 >= 2020`, logExpr{or, re1, re2, "index1"}},
|
||||
parseResult{`(index1 = 2015) or index1 >= 2020`, logExpr{or, re1, re2, "index1"}},
|
||||
parseResult{`index1 = 2015 or (index1 >= 2020)`, logExpr{or, re1, re2, "index1"}},
|
||||
parseResult{`(index1 = 2015 or index1 >= 2020)`, logExpr{or, re1, re2, "index1"}},
|
||||
parseResult{`(index1 = 2015 or index1 >= 2020) and index1 <= 2022`, logExpr{and, logExpr{or, re1, re2, "index1"}, re3, "index1"}},
|
||||
parseResult{`index1 = 2015 or index1 >= 2020 and index1 <= 2022`, logExpr{or, re1, logExpr{and, re2, re3, "index1"}, "index1"}},
|
||||
parseResult{`index1 = 2015 or index1 >= 2020 and index1 <= 2022 or index1 < -2030`, logExpr{or, re1, logExpr{and, re2, logExpr{or, re3, re4, "index1"}, "index1"}, "index1"}},
|
||||
parseResult{`(index1 = 2015 or index1 >= 2020) and (index1 <= 2022 or index1 < -2030)`, logExpr{and, logExpr{or, re1, re2, "index1"}, logExpr{or, re3, re4, "index1"}, "index1"}},
|
||||
{`index1 = 2015`, re1},
|
||||
{`(index1 = 2015 )`, re1},
|
||||
{`(((index1 = 2015 ) ))`, re1},
|
||||
{`index1 = 2015 or index1 >= 2020`, logExpr{or, re1, re2, "index1"}},
|
||||
{`(index1 = 2015) or index1 >= 2020`, logExpr{or, re1, re2, "index1"}},
|
||||
{`index1 = 2015 or (index1 >= 2020)`, logExpr{or, re1, re2, "index1"}},
|
||||
{`(index1 = 2015 or index1 >= 2020)`, logExpr{or, re1, re2, "index1"}},
|
||||
{`(index1 = 2015 or index1 >= 2020) and index1 <= 2022`, logExpr{and, logExpr{or, re1, re2, "index1"}, re3, "index1"}},
|
||||
{`index1 = 2015 or index1 >= 2020 and index1 <= 2022`, logExpr{or, re1, logExpr{and, re2, re3, "index1"}, "index1"}},
|
||||
{`index1 = 2015 or index1 >= 2020 and index1 <= 2022 or index1 < -2030`, logExpr{or, re1, logExpr{and, re2, logExpr{or, re3, re4, "index1"}, "index1"}, "index1"}},
|
||||
{`(index1 = 2015 or index1 >= 2020) and (index1 <= 2022 or index1 < -2030)`, logExpr{and, logExpr{or, re1, re2, "index1"}, logExpr{or, re3, re4, "index1"}, "index1"}},
|
||||
}
|
||||
|
||||
db := datas.NewDatabase(chunks.NewMemoryStore())
|
||||
|
||||
@@ -96,7 +96,7 @@ func (r queryRange) and(o queryRange) (rangeDescs queryRangeSlice) {
|
||||
|
||||
lower := r.lower.maxValue(o.lower)
|
||||
upper := r.upper.minValue(o.upper)
|
||||
return []queryRange{queryRange{lower, upper}}
|
||||
return []queryRange{{lower, upper}}
|
||||
}
|
||||
|
||||
func (r queryRange) or(o queryRange) (rSlice queryRangeSlice) {
|
||||
|
||||
Reference in New Issue
Block a user