Skip to content

Commit

Permalink
fix linter warnings (#12286)
Browse files Browse the repository at this point in the history
* fix linter warnings

Signed-off-by: Andres Taylor <[email protected]>

* add the same checks in CI as pre-commit

Signed-off-by: Andres Taylor <[email protected]>

* ci: disable revive by default

Signed-off-by: Vicent Marti <[email protected]>

---------

Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Vicent Marti <[email protected]>
Co-authored-by: Vicent Marti <[email protected]>
  • Loading branch information
systay and vmg authored Feb 9, 2023
1 parent d208d36 commit 07c85db
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions go/vt/vtgate/evalengine/api_arithmetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Add(v1, v2 sqltypes.Value) (sqltypes.Value, error) {
if err != nil {
return sqltypes.NULL, err
}
return evalToSqlValue(r), nil
return evalToSQLValue(r), nil
}

// Subtract takes two values and subtracts them
Expand All @@ -91,7 +91,7 @@ func Subtract(v1, v2 sqltypes.Value) (sqltypes.Value, error) {
if err != nil {
return sqltypes.NULL, err
}
return evalToSqlValue(r), nil
return evalToSQLValue(r), nil
}

// Multiply takes two values and multiplies it together
Expand All @@ -111,7 +111,7 @@ func Multiply(v1, v2 sqltypes.Value) (sqltypes.Value, error) {
if err != nil {
return sqltypes.NULL, err
}
return evalToSqlValue(r), nil
return evalToSQLValue(r), nil
}

// Divide (Float) for MySQL. Replicates behavior of "/" operator
Expand All @@ -131,7 +131,7 @@ func Divide(v1, v2 sqltypes.Value) (sqltypes.Value, error) {
if err != nil {
return sqltypes.NULL, err
}
return evalToSqlValue(r), nil
return evalToSQLValue(r), nil
}

// NullSafeAdd adds two Values in a null-safe manner. A null value
Expand Down
14 changes: 7 additions & 7 deletions go/vt/vtgate/evalengine/api_arithmetic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func TestArithmetics(t *testing.T) {
operator: "/",
f: Divide,
cases: []tcase{{
//All Nulls
// All Nulls
v1: NULL,
v2: NULL,
out: NULL,
Expand Down Expand Up @@ -355,7 +355,7 @@ func TestArithmetics(t *testing.T) {
operator: "*",
f: Multiply,
cases: []tcase{{
//All Nulls
// All Nulls
v1: NULL,
v2: NULL,
out: NULL,
Expand Down Expand Up @@ -424,7 +424,7 @@ func TestArithmetics(t *testing.T) {
v2: NewUint64(1),
out: NewUint64(math.MaxUint64),
}, {
//Checking whether maxInt value can be passed as uint value
// Checking whether maxInt value can be passed as uint value
v1: NewUint64(math.MaxInt64),
v2: NewInt64(3),
err: dataOutOfRangeError(math.MaxInt64, 3, "BIGINT UNSIGNED", "*").Error(),
Expand Down Expand Up @@ -984,10 +984,10 @@ func TestPrioritize(t *testing.T) {
out2: ival,
}}
for _, tcase := range tcases {
t.Run(fmt.Sprintf("%s - %s", evalToSqlValue(tcase.v1), evalToSqlValue(tcase.v2)), func(t *testing.T) {
t.Run(fmt.Sprintf("%s - %s", evalToSQLValue(tcase.v1), evalToSQLValue(tcase.v2)), func(t *testing.T) {
got1, got2 := makeNumericAndPrioritize(tcase.v1, tcase.v2)
utils.MustMatch(t, evalToSqlValue(tcase.out1), evalToSqlValue(got1), "makeNumericAndPrioritize")
utils.MustMatch(t, evalToSqlValue(tcase.out2), evalToSqlValue(got2), "makeNumericAndPrioritize")
utils.MustMatch(t, evalToSQLValue(tcase.out1), evalToSQLValue(got1), "makeNumericAndPrioritize")
utils.MustMatch(t, evalToSQLValue(tcase.out2), evalToSQLValue(got2), "makeNumericAndPrioritize")
})
}
}
Expand Down Expand Up @@ -1089,7 +1089,7 @@ func TestCompareNumeric(t *testing.T) {

for aIdx, aVal := range values {
for bIdx, bVal := range values {
t.Run(fmt.Sprintf("[%d/%d] %s %s", aIdx, bIdx, evalToSqlValue(aVal), evalToSqlValue(bVal)), func(t *testing.T) {
t.Run(fmt.Sprintf("[%d/%d] %s %s", aIdx, bIdx, evalToSQLValue(aVal), evalToSQLValue(bVal)), func(t *testing.T) {
result, err := compareNumeric(aVal, bVal)
require.NoError(t, err)
assert.Equal(t, cmpResults[aIdx][bIdx], result)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/evalengine/api_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func LiteralToValue(literal *sqlparser.Literal) (sqltypes.Value, error) {
if err != nil {
return sqltypes.Value{}, err
}
return evalToSqlValue(lit.inner), nil
return evalToSQLValue(lit.inner), nil
}

// ToNative converts Value to a native go type.
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/evalengine/arithmetic.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func addNumericWithError(left, right eval) (eval, error) {
case *evalFloat:
return floatPlusAny(v1.f, v2)
}
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "invalid arithmetic between: %s %s", evalToSqlValue(v1), evalToSqlValue(v2))
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "invalid arithmetic between: %s %s", evalToSQLValue(v1), evalToSQLValue(v2))
}

func subtractNumericWithError(left, right eval) (eval, error) {
Expand Down Expand Up @@ -87,7 +87,7 @@ func subtractNumericWithError(left, right eval) (eval, error) {
return decimalMinusAny(v1, v2)
}
}
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "invalid arithmetic between: %s %s", evalToSqlValue(v1), evalToSqlValue(v2))
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "invalid arithmetic between: %s %s", evalToSQLValue(v1), evalToSQLValue(v2))
}

func multiplyNumericWithError(left, right eval) (eval, error) {
Expand All @@ -107,7 +107,7 @@ func multiplyNumericWithError(left, right eval) (eval, error) {
case *evalDecimal:
return decimalTimesAny(v1, v2)
}
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "invalid arithmetic between: %s %s", evalToSqlValue(v1), evalToSqlValue(v2))
return nil, vterrors.Errorf(vtrpcpb.Code_INTERNAL, "invalid arithmetic between: %s %s", evalToSQLValue(v1), evalToSQLValue(v2))
}

func divideNumericWithError(left, right eval, precise bool) (eval, error) {
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/evalengine/casting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ func TestEvalResultToBooleanStrict(t *testing.T) {
}

for _, res := range trueValues {
name := evalToSqlValue(res).String()
name := evalToSQLValue(res).String()
t.Run(fmt.Sprintf("ToBooleanStrict() %s expected true (success)", name), func(t *testing.T) {
result, err := (&EvalResult{res}).ToBooleanStrict()
require.NoError(t, err, name)
require.Equal(t, true, result, name)
})
}
for _, res := range falseValues {
name := evalToSqlValue(res).String()
name := evalToSQLValue(res).String()
t.Run(fmt.Sprintf("ToBooleanStrict() %s expected false (success)", name), func(t *testing.T) {
result, err := (&EvalResult{res}).ToBooleanStrict()
require.NoError(t, err, name)
require.Equal(t, false, result, name)
})
}
for _, res := range invalid {
name := evalToSqlValue(res).String()
name := evalToSQLValue(res).String()
t.Run(fmt.Sprintf("ToBooleanStrict() %s expected fail", name), func(t *testing.T) {
_, err := (&EvalResult{res}).ToBooleanStrict()
require.Error(t, err)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/evalengine/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type eval interface {
hash() (HashCode, error)
}

func evalToSqlValue(e eval) sqltypes.Value {
func evalToSQLValue(e eval) sqltypes.Value {
if e == nil {
return sqltypes.NULL
}
Expand Down
6 changes: 3 additions & 3 deletions go/vt/vtgate/evalengine/eval_numeric.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ func (e *evalDecimal) toUint64() *evalUint64 {
if dec.Sign() < 0 {
i, _ := dec.Int64()
return newEvalUint64(uint64(i))
} else {
u, _ := dec.Uint64()
return newEvalUint64(u)
}

u, _ := dec.Uint64()
return newEvalUint64(u)
}
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/eval_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type EvalResult struct {

// Value allows for retrieval of the value we expose for public consumption
func (er EvalResult) Value() sqltypes.Value {
return evalToSqlValue(er.v)
return evalToSQLValue(er.v)
}

func (er EvalResult) Collation() collations.ID {
Expand All @@ -48,7 +48,7 @@ func (er EvalResult) TupleValues() []sqltypes.Value {
case *evalTuple:
result := make([]sqltypes.Value, 0, len(v.t))
for _, val := range v.t {
result = append(result, evalToSqlValue(val))
result = append(result, evalToSQLValue(val))
}
return result
default:
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func (l *Literal) format(w *formatter, depth int) {
if i > 0 {
w.WriteString(", ")
}
w.WriteString(evalToSqlValue(val).String())
w.WriteString(evalToSQLValue(val).String())
}
w.WriteByte(')')

default:
w.WriteString(evalToSqlValue(l.inner).String())
w.WriteString(evalToSQLValue(l.inner).String())
}
}

Expand Down
2 changes: 1 addition & 1 deletion misc/git/hooks/golangci-lint
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ fi
gopackages=$(echo "$gofiles" | xargs -n1 dirname | sort -u | paste -sd ' ' -)

echo "Linting $gopackages"
golangci-lint run -E revive $gopackages
golangci-lint run $gopackages

0 comments on commit 07c85db

Please sign in to comment.