Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: linting #15620

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
840d719
gofumpt
tac0turtle Mar 29, 2023
abf2021
second round of linting
tac0turtle Mar 29, 2023
a83c424
if
tac0turtle Mar 29, 2023
ceca48a
ensure changes
faddat Mar 30, 2023
3885257
Merge branch 'main' into orm-module
faddat Mar 30, 2023
7e70f08
remove new linters
faddat Mar 30, 2023
98c4a7e
Merge branch 'main' into orm-module
faddat Mar 30, 2023
527fbcf
more linting
tac0turtle Mar 30, 2023
9858d71
more linting
tac0turtle Mar 30, 2023
4b6be99
Merge branch 'main' into marko/linting_3
tac0turtle Mar 30, 2023
7e71024
fix test
tac0turtle Mar 30, 2023
1eccf8b
more cleanup
tac0turtle Mar 30, 2023
08a33fc
Merge branch 'main' into marko/linting_3
tac0turtle Mar 30, 2023
0f58ab9
more linting
tac0turtle Mar 30, 2023
dafc599
some more
tac0turtle Mar 30, 2023
eef0b5d
Merge branch 'main' into orm-module
faddat Mar 30, 2023
3a8b5e5
revert changes to .golangci.yml
faddat Mar 30, 2023
668416c
some more
tac0turtle Mar 30, 2023
9ae6c9a
Merge remote-tracking branch 'origin/marko/linting_3' into more
faddat Mar 30, 2023
d74c7a3
Merge remote-tracking branch 'origin/marko/linting_4' into more
faddat Mar 30, 2023
03fd902
remove depreacted
tac0turtle Mar 30, 2023
73cc772
configure gosec
faddat Mar 30, 2023
18ba79a
more ;)
faddat Mar 30, 2023
ce432ea
put a revive config stub in the linter config
faddat Mar 30, 2023
47ed2b4
Merge branch 'main' into marko/linting_4
tac0turtle Mar 30, 2023
01c218a
Merge remote-tracking branch 'origin/marko/linting_4' into more
faddat Mar 30, 2023
87a8a2d
more lints
faddat Mar 30, 2023
603af7e
Merge remote-tracking branch 'origin/main' into more
faddat Mar 30, 2023
9835152
Merge branch 'main' into more
faddat Mar 30, 2023
97fc34b
Merge branch 'main' into more
faddat Mar 30, 2023
d9e72ee
Merge branch 'main' into more
faddat Mar 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const (
var _ abci.Application = (*BaseApp)(nil)

// BaseApp reflects the ABCI application implementation.
type BaseApp struct { //nolint: maligned
type BaseApp struct {
// initialized on creation
logger log.Logger
name string // application name from abci.Info
Expand Down
10 changes: 5 additions & 5 deletions client/tx/tx_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tx_test

import (
gocontext "context"
"context"
"fmt"
"strings"
"testing"
Expand Down Expand Up @@ -40,7 +40,7 @@ type mockContext struct {
wantErr bool
}

func (m mockContext) Invoke(grpcCtx gocontext.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) {
func (m mockContext) Invoke(grpcCtx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) {
if m.wantErr {
return fmt.Errorf("mock err")
}
Expand All @@ -53,7 +53,7 @@ func (m mockContext) Invoke(grpcCtx gocontext.Context, method string, req, reply
return nil
}

func (mockContext) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) {
func (mockContext) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) {
panic("not implemented")
}

Expand Down Expand Up @@ -347,7 +347,7 @@ func TestSign(t *testing.T) {
var prevSigs []signingtypes.SignatureV2
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite) //nolint:staticcheck
err = tx.Sign(context.TODO(), tc.txf, tc.from, tc.txb, tc.overwrite)
if len(tc.expectedPKs) == 0 {
requireT.Error(err)
} else {
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestPreprocessHook(t *testing.T) {
txb, err := txfDirect.BuildUnsignedTx(msg1, msg2)
requireT.NoError(err)

err = tx.Sign(nil, txfDirect, from, txb, false) //nolint:staticcheck
err = tx.Sign(context.TODO(), txfDirect, from, txb, false)
requireT.NoError(err)

// Run preprocessing
Expand Down
2 changes: 0 additions & 2 deletions codec/proto_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Messa
// it marshals to JSON using proto codec.
// NOTE: this function must be used with a concrete type which
// implements proto.Message. For interface please use the codec.MarshalInterfaceJSON
//
//nolint:stdmethods
func (pc *ProtoCodec) MarshalJSON(o gogoproto.Message) ([]byte, error) {
if o == nil {
return nil, fmt.Errorf("cannot protobuf JSON encode nil")
Expand Down
1 change: 0 additions & 1 deletion codec/types/any.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// nolint
package types

import (
Expand Down
2 changes: 1 addition & 1 deletion codec/types/any_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (d Dog) Greet() string { return d.Name }
func (d *Dog) Reset() { d.Name = "" }
func (d *Dog) String() string { return d.Name }
func (d *Dog) ProtoMessage() {}
func (d *Dog) XXX_MessageName() string { return "tests/dog" } //nolint:revive
func (d *Dog) XXX_MessageName() string { return "tests/dog" }

type Animal interface {
Greet() string
Expand Down
2 changes: 1 addition & 1 deletion codec/types/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var _ proto.Message = (*errOnMarshal)(nil)

var errAlways = fmt.Errorf("always erroring")

func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive
func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive // ignore var-naming here
return nil, errAlways
}

Expand Down
2 changes: 1 addition & 1 deletion codec/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
func (dog FakeDog) Reset() {}
func (dog FakeDog) String() string { return "fakedog" }
func (dog FakeDog) ProtoMessage() {}
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive // ignore var-naming here
func (dog FakeDog) Greet() string { return "fakedog" }

func TestRegister(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions crypto/hd/hdpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestDeriveHDPathRange(t *testing.T) {
}
}

func ExampleStringifyPathParams() { //nolint:govet
func ExampleStringifyPathParams() {
path := hd.NewParams(44, 0, 0, false, 0)
fmt.Println(path.String())
path = hd.NewParams(44, 33, 7, true, 9)
Expand All @@ -195,7 +195,7 @@ func ExampleStringifyPathParams() { //nolint:govet
// m/44'/33'/7'/1/9
}

func ExampleSomeBIP32TestVecs() { //nolint:govet
func ExampleSomeBIP32TestVecs() {
seed := mnemonicToSeed("barrel original fuel morning among eternal " +
"filter ball stove pluck matrix mechanic")
master, ch := hd.ComputeMastersFromSeed(seed)
Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/bcrypt/bcrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cip
// Bug compatibility with C bcrypt implementations. They use the trailing
// NULL in the key string during expansion.
// We copy the key to prevent changing the underlying array.
ckey := append(key[:len(key):len(key)], 0) //nolint:gocritic // used in original https://cs.opensource.google/go/x/crypto/+/master:bcrypt/bcrypt.go
ckey := append(key[:len(key):len(key)], 0)

c, err := blowfish.NewSaltedCipher(ckey, csalt)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/multisig/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func tmToProto(tmPk tmMultisig) (*LegacyAminoPubKey, error) {
}

// MarshalAminoJSON overrides amino JSON unmarshaling.
func (m LegacyAminoPubKey) MarshalAminoJSON() (tmMultisig, error) { //nolint:golint,revive
func (m LegacyAminoPubKey) MarshalAminoJSON() (tmMultisig, error) {
return protoToTm(&m)
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/secp256k1/secp256k1_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Test_genPrivKey(t *testing.T) {
copy(onePadded[32-len(oneB):32], oneB)
t.Logf("one padded: %v, len=%v", onePadded, len(onePadded))

validOne := append(empty, onePadded...) //nolint:gocritic // append is fine here
validOne := append(empty, onePadded...)
tests := []struct {
name string
notSoRand []byte
Expand Down
2 changes: 1 addition & 1 deletion crypto/ledger/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func checkAminoJSON(t *testing.T, src, dst interface{}, isNil bool) {
require.Nil(t, err, "%+v", err)
}

func ExamplePrintRegisteredTypes() { //nolint:govet
func ExamplePrintRegisteredTypes() {
_ = cdc.PrintTypes(os.Stdout)
// | Type | Name | Prefix | Length | Notes |
// | ---- | ---- | ------ | ----- | ------ |
Expand Down
2 changes: 1 addition & 1 deletion internal/conv/string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *StringSuite) TestUnsafeStrToBytes() {
b := unsafeConvertStr()
runtime.GC()
<-time.NewTimer(2 * time.Millisecond).C
b2 := append(b, 'd') //nolint:gocritic // append is fine here
b2 := append(b, 'd')
s.Equal("abc", string(b))
s.Equal("abcd", string(b2))
}
Expand Down
3 changes: 1 addition & 2 deletions orm/cmd/protoc-gen-go-cosmos-orm-proto/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package main

import (
"google.golang.org/protobuf/compiler/protogen"

"github.com/cosmos/cosmos-sdk/orm/internal/codegen"
"google.golang.org/protobuf/compiler/protogen"
)

func main() {
Expand Down
3 changes: 1 addition & 2 deletions orm/cmd/protoc-gen-go-cosmos-orm/main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package main

import (
"google.golang.org/protobuf/compiler/protogen"

"github.com/cosmos/cosmos-sdk/orm/internal/codegen"
"google.golang.org/protobuf/compiler/protogen"
)

func main() {
Expand Down
11 changes: 6 additions & 5 deletions orm/encoding/encodeutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
func SkipPrefix(r *bytes.Reader, prefix []byte) error {
n := len(prefix)
if n > 0 {
// we skip checking the prefix for performance reasons because we assume
// that it was checked by the caller
// We skip checking the prefix for performance reasons because we assume
// that it was checked by the caller.
_, err := r.Seek(int64(n), io.SeekCurrent)

return err
}
return nil
Expand All @@ -33,12 +34,12 @@ func AppendVarUInt32(prefix []byte, x uint32) []byte {
}

// ValuesOf takes the arguments and converts them to protoreflect.Value's.
func ValuesOf(values ...interface{}) []protoreflect.Value {
func ValuesOf(values ...any) []protoreflect.Value {
n := len(values)
res := make([]protoreflect.Value, n)
for i := 0; i < n; i++ {
// we catch the case of proto messages here and call ProtoReflect.
// this allows us to use imported messages, such as timestamppb.Timestamp
// We catch the case of proto messages here and call ProtoReflect.
// This allows us to use imported messages, such as timestamppb.Timestamp
// in iterators.
value := values[i]
switch value.(type) {
Expand Down
10 changes: 5 additions & 5 deletions orm/encoding/ormfield/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
// BoolCodec encodes a bool value as a single byte 0 or 1.
type BoolCodec struct{}

func (b BoolCodec) Decode(r Reader) (protoreflect.Value, error) {
func (BoolCodec) Decode(r Reader) (protoreflect.Value, error) {
x, err := r.ReadByte()
return protoreflect.ValueOfBool(x != 0), err
}
Expand All @@ -19,7 +19,7 @@ var (
oneBz = []byte{1}
)

func (b BoolCodec) Encode(value protoreflect.Value, w io.Writer) error {
func (BoolCodec) Encode(value protoreflect.Value, w io.Writer) error {
var err error
if !value.IsValid() || !value.Bool() {
_, err = w.Write(zeroBz)
Expand All @@ -29,7 +29,7 @@ func (b BoolCodec) Encode(value protoreflect.Value, w io.Writer) error {
return err
}

func (b BoolCodec) Compare(v1, v2 protoreflect.Value) int {
func (BoolCodec) Compare(v1, v2 protoreflect.Value) int {
var b1, b2 bool
if v1.IsValid() {
b1 = v1.Bool()
Expand All @@ -46,11 +46,11 @@ func (b BoolCodec) Compare(v1, v2 protoreflect.Value) int {
}
}

func (b BoolCodec) IsOrdered() bool {
func (BoolCodec) IsOrdered() bool {
return false
}

func (b BoolCodec) FixedBufferSize() int {
func (BoolCodec) FixedBufferSize() int {
return 1
}

Expand Down
26 changes: 13 additions & 13 deletions orm/encoding/ormfield/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
// than 255 bytes.
type BytesCodec struct{}

func (b BytesCodec) FixedBufferSize() int {
func (BytesCodec) FixedBufferSize() int {
return -1
}

// ComputeBufferSize returns the bytes size of the value.
func (b BytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error) {
func (BytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error) {
return bytesSize(value), nil
}

Expand All @@ -28,57 +28,57 @@ func bytesSize(value protoreflect.Value) int {
return len(value.Bytes())
}

func (b BytesCodec) IsOrdered() bool {
func (BytesCodec) IsOrdered() bool {
return false
}

func (b BytesCodec) Decode(r Reader) (protoreflect.Value, error) {
func (BytesCodec) Decode(r Reader) (protoreflect.Value, error) {
bz, err := io.ReadAll(r)
return protoreflect.ValueOfBytes(bz), err
}

func (b BytesCodec) Encode(value protoreflect.Value, w io.Writer) error {
func (BytesCodec) Encode(value protoreflect.Value, w io.Writer) error {
if !value.IsValid() {
return nil
}
_, err := w.Write(value.Bytes())
return err
}

func (b BytesCodec) Compare(v1, v2 protoreflect.Value) int {
func (BytesCodec) Compare(v1, v2 protoreflect.Value) int {
return compareBytes(v1, v2)
}

// NonTerminalBytesCodec encodes bytes as raw bytes length prefixed by a single
// byte. It errors if the byte array is longer than 255 bytes.
type NonTerminalBytesCodec struct{}

func (b NonTerminalBytesCodec) FixedBufferSize() int {
func (NonTerminalBytesCodec) FixedBufferSize() int {
return -1
}

// ComputeBufferSize returns the bytes size of the value plus the length of the
// varint length-prefix.
func (b NonTerminalBytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error) {
func (NonTerminalBytesCodec) ComputeBufferSize(value protoreflect.Value) (int, error) {
n := bytesSize(value)
prefixLen := 1
// we use varint, if the first bit of a byte is 1 then we need to signal continuation
// We use varint, if the first bit of a byte is 1 then we need to signal continuation.
for n >= 0x80 {
prefixLen++
n >>= 7
}
return n + prefixLen, nil
}

func (b NonTerminalBytesCodec) IsOrdered() bool {
func (NonTerminalBytesCodec) IsOrdered() bool {
return false
}

func (b NonTerminalBytesCodec) Compare(v1, v2 protoreflect.Value) int {
func (NonTerminalBytesCodec) Compare(v1, v2 protoreflect.Value) int {
return compareBytes(v1, v2)
}

func (b NonTerminalBytesCodec) Decode(r Reader) (protoreflect.Value, error) {
func (NonTerminalBytesCodec) Decode(r Reader) (protoreflect.Value, error) {
n, err := binary.ReadUvarint(r)
if err != nil {
return protoreflect.Value{}, err
Expand All @@ -93,7 +93,7 @@ func (b NonTerminalBytesCodec) Decode(r Reader) (protoreflect.Value, error) {
return protoreflect.ValueOfBytes(bz), err
}

func (b NonTerminalBytesCodec) Encode(value protoreflect.Value, w io.Writer) error {
func (NonTerminalBytesCodec) Encode(value protoreflect.Value, w io.Writer) error {
var bz []byte
if value.IsValid() {
bz = value.Bytes()
Expand Down
Loading