chore: linting (#15813)
This commit is contained in:
@@ -37,11 +37,12 @@ func (b BoolCodec) Compare(v1, v2 protoreflect.Value) int {
|
||||
if v2.IsValid() {
|
||||
b2 = v2.Bool()
|
||||
}
|
||||
if b1 == b2 {
|
||||
switch {
|
||||
case b1 == b2:
|
||||
return 0
|
||||
} else if b1 {
|
||||
case b1:
|
||||
return -1
|
||||
} else {
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,15 +72,16 @@ func GetCodec(field protoreflect.FieldDescriptor, nonTerminal bool) (Codec, erro
|
||||
case protoreflect.BytesKind:
|
||||
if nonTerminal {
|
||||
return NonTerminalBytesCodec{}, nil
|
||||
} else {
|
||||
return BytesCodec{}, nil
|
||||
}
|
||||
|
||||
return BytesCodec{}, nil
|
||||
case protoreflect.StringKind:
|
||||
if nonTerminal {
|
||||
return NonTerminalStringCodec{}, nil
|
||||
} else {
|
||||
return StringCodec{}, nil
|
||||
}
|
||||
|
||||
return StringCodec{}, nil
|
||||
|
||||
case protoreflect.Uint32Kind:
|
||||
return CompactUint32Codec{}, nil
|
||||
case protoreflect.Fixed32Kind:
|
||||
|
||||
@@ -108,11 +108,12 @@ func TestCompactUInt32(t *testing.T) {
|
||||
by := ormfield.EncodeCompactUint32(y)
|
||||
|
||||
cmp := bytes.Compare(bx, by)
|
||||
if x < y {
|
||||
switch {
|
||||
case x < y:
|
||||
assert.Equal(t, -1, cmp)
|
||||
} else if x == y {
|
||||
case x == y:
|
||||
assert.Equal(t, 0, cmp)
|
||||
} else {
|
||||
default:
|
||||
assert.Equal(t, 1, cmp)
|
||||
}
|
||||
|
||||
@@ -156,11 +157,12 @@ func TestCompactUInt64(t *testing.T) {
|
||||
by := ormfield.EncodeCompactUint64(y)
|
||||
|
||||
cmp := bytes.Compare(bx, by)
|
||||
if x < y {
|
||||
switch {
|
||||
case x < y:
|
||||
assert.Equal(t, -1, cmp)
|
||||
} else if x == y {
|
||||
case x == y:
|
||||
assert.Equal(t, 0, cmp)
|
||||
} else {
|
||||
default:
|
||||
assert.Equal(t, 1, cmp)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ func (d DurationCodec) Compare(v1, v2 protoreflect.Value) int {
|
||||
c := compareInt(s1, s2)
|
||||
if c != 0 {
|
||||
return c
|
||||
} else {
|
||||
return compareInt(n1, n2)
|
||||
}
|
||||
|
||||
return compareInt(n1, n2)
|
||||
}
|
||||
|
||||
func (d DurationCodec) IsOrdered() bool {
|
||||
|
||||
@@ -34,11 +34,12 @@ func (e EnumCodec) Compare(v1, v2 protoreflect.Value) int {
|
||||
if v2.IsValid() {
|
||||
y = v2.Enum()
|
||||
}
|
||||
if x == y {
|
||||
switch {
|
||||
case x == y:
|
||||
return 0
|
||||
} else if x < y {
|
||||
case x < y:
|
||||
return -1
|
||||
} else {
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ func (i Int64Codec) Decode(r Reader) (protoreflect.Value, error) {
|
||||
if x >= int64Max {
|
||||
x = x - int64Max - 1
|
||||
return protoreflect.ValueOfInt64(int64(x)), err
|
||||
} else {
|
||||
y := int64(x) - int64Max - 1
|
||||
return protoreflect.ValueOfInt64(y), err
|
||||
}
|
||||
|
||||
y := int64(x) - int64Max - 1
|
||||
return protoreflect.ValueOfInt64(y), err
|
||||
}
|
||||
|
||||
func (i Int64Codec) Encode(value protoreflect.Value, w io.Writer) error {
|
||||
@@ -36,11 +36,11 @@ func (i Int64Codec) Encode(value protoreflect.Value, w io.Writer) error {
|
||||
if x >= -1 {
|
||||
y := uint64(x) + int64Max + 1
|
||||
return binary.Write(w, binary.BigEndian, y)
|
||||
} else {
|
||||
x += int64Max
|
||||
x += 1
|
||||
return binary.Write(w, binary.BigEndian, uint64(x))
|
||||
}
|
||||
|
||||
x += int64Max
|
||||
x++
|
||||
return binary.Write(w, binary.BigEndian, uint64(x))
|
||||
}
|
||||
|
||||
func (i Int64Codec) Compare(v1, v2 protoreflect.Value) int {
|
||||
@@ -67,11 +67,12 @@ func compareInt(v1, v2 protoreflect.Value) int {
|
||||
if v2.IsValid() {
|
||||
y = v2.Int()
|
||||
}
|
||||
if x == y {
|
||||
switch {
|
||||
case x == y:
|
||||
return 0
|
||||
} else if x < y {
|
||||
case x < y:
|
||||
return -1
|
||||
} else {
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (t TimestampCodec) Encode(value protoreflect.Value, w io.Writer) error {
|
||||
nanosBz[i] = byte(nanosInt)
|
||||
nanosInt >>= 8
|
||||
}
|
||||
nanosBz[0] = nanosBz[0] | 0xC0
|
||||
nanosBz[0] |= 0xC0
|
||||
_, err = w.Write(nanosBz[:])
|
||||
return err
|
||||
}
|
||||
@@ -151,9 +151,9 @@ func (t TimestampCodec) Compare(v1, v2 protoreflect.Value) int {
|
||||
c := compareInt(s1, s2)
|
||||
if c != 0 {
|
||||
return c
|
||||
} else {
|
||||
return compareInt(n1, n2)
|
||||
}
|
||||
|
||||
return compareInt(n1, n2)
|
||||
}
|
||||
|
||||
func (t TimestampCodec) IsOrdered() bool {
|
||||
@@ -215,9 +215,9 @@ func (t TimestampV0Codec) Compare(v1, v2 protoreflect.Value) int {
|
||||
c := compareInt(s1, s2)
|
||||
if c != 0 {
|
||||
return c
|
||||
} else {
|
||||
return compareInt(n1, n2)
|
||||
}
|
||||
|
||||
return compareInt(n1, n2)
|
||||
}
|
||||
|
||||
func (t TimestampV0Codec) IsOrdered() bool {
|
||||
|
||||
@@ -49,11 +49,12 @@ func compareUint(v1, v2 protoreflect.Value) int {
|
||||
if v2.IsValid() {
|
||||
y = v2.Uint()
|
||||
}
|
||||
if x == y {
|
||||
switch {
|
||||
case x == y:
|
||||
return 0
|
||||
} else if x < y {
|
||||
case x < y:
|
||||
return -1
|
||||
} else {
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user