chore: linting (#15813)

This commit is contained in:
Marko
2023-04-12 12:36:42 +00:00
committed by GitHub
parent 00e1f85eca
commit 37032fb948
35 changed files with 150 additions and 138 deletions
+4 -3
View File
@@ -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
}
}
+5 -4
View File
@@ -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:
+8 -6
View File
@@ -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)
}
+2 -2
View File
@@ -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 {
+4 -3
View File
@@ -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
}
}
+11 -10
View File
@@ -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
}
}
+5 -5
View File
@@ -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 {
+4 -3
View File
@@ -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
}
}