Skip to content

Commit

Permalink
style: gofumpt linting (#15605)
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Mar 30, 2023
1 parent 24344fb commit 1f2875d
Show file tree
Hide file tree
Showing 56 changed files with 97 additions and 97 deletions.
3 changes: 2 additions & 1 deletion client/v2/autocli/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*co
Builder: flag.Builder{
GetClientConn: func() (grpc.ClientConnInterface, error) {
return conn, nil
}},
},
},
GetClientConn: func(*cobra.Command) (grpc.ClientConnInterface, error) {
return conn, nil
},
Expand Down
3 changes: 1 addition & 2 deletions client/v2/autocli/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func TestJSONParsing(t *testing.T) {
"-u", "27", // shorthand
)
assert.DeepEqual(t, conn.lastRequest, conn.lastResponse.(*testpb.EchoResponse).Request, protocmp.Transform())

}

func TestOptions(t *testing.T) {
Expand Down Expand Up @@ -319,7 +318,7 @@ type testClientConn struct {
errorOut *bytes.Buffer
}

func (t *testClientConn) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error {
func (t *testClientConn) Invoke(ctx context.Context, method string, args, reply interface{}, opts ...grpc.CallOption) error {
err := t.ClientConn.Invoke(ctx, method, args, reply, opts...)
t.lastRequest = args
t.lastResponse = reply
Expand Down
2 changes: 1 addition & 1 deletion collections/indexes/multi_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type pairKeyCodec[K1, K2 any] interface {
// NewMultiPair instantiates a new MultiPair index.
// NOTE: when using this function you will need to type hint: doing NewMultiPair[Value]()
// Example: if the value of the indexed map is string, you need to do NewMultiPair[string](...)
func NewMultiPair[Value any, K1, K2 any](
func NewMultiPair[Value, K1, K2 any](
sb *collections.SchemaBuilder,
prefix collections.Prefix,
name string,
Expand Down
4 changes: 2 additions & 2 deletions collections/iter.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type Ranger[K any] interface {
// iteration will yield keys from the smallest to the biggest, if order
// is OrderDescending then the iteration will yield keys from the biggest to the smallest.
// Ordering is defined by the keys bytes representation, which is dependent on the KeyCodec used.
RangeValues() (start *RangeKey[K], end *RangeKey[K], order Order, err error)
RangeValues() (start, end *RangeKey[K], order Order, err error)
}

// Range is a Ranger implementer.
Expand Down Expand Up @@ -126,7 +126,7 @@ var (
errOrder = errors.New("collections: invalid order")
)

func (r *Range[K]) RangeValues() (start *RangeKey[K], end *RangeKey[K], order Order, err error) {
func (r *Range[K]) RangeValues() (start, end *RangeKey[K], order Order, err error) {
return r.start, r.end, r.order, nil
}

Expand Down
2 changes: 1 addition & 1 deletion collections/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func TestWalk(t *testing.T) {
}

u := uint64(0)
err = m.Walk(ctx, nil, func(key uint64, value uint64) bool {
err = m.Walk(ctx, nil, func(key, value uint64) bool {
if key == 5 {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion collections/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (p *PairRange[K1, K2]) Descending() *PairRange[K1, K2] {
return p
}

func (p *PairRange[K1, K2]) RangeValues() (start *RangeKey[Pair[K1, K2]], end *RangeKey[Pair[K1, K2]], order Order, err error) {
func (p *PairRange[K1, K2]) RangeValues() (start, end *RangeKey[Pair[K1, K2]], order Order, err error) {
if p.err != nil {
return nil, nil, 0, err
}
Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/secp256k1/secp256k1_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) {

// VerifySignature validates the signature.
// The msg will be hashed prior to signature verification.
func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool {
func (pubKey *PubKey) VerifySignature(msg, sigStr []byte) bool {
return secp256k1.VerifySignature(pubKey.Bytes(), crypto.Sha256(msg), sigStr)
}
6 changes: 3 additions & 3 deletions depinject/binding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ func fullTypeName(typeName string) string {
return fmt.Sprintf("cosmossdk.io/depinject_test/depinject_test.%s", typeName)
}

func (s *bindingSuite) ThereIsAGlobalBindingForA(preferredType string, interfaceType string) {
func (s *bindingSuite) ThereIsAGlobalBindingForA(preferredType, interfaceType string) {
s.addConfig(depinject.BindInterface(fullTypeName(interfaceType), fullTypeName(preferredType)))
}

func (s *bindingSuite) ThereIsABindingForAInModule(preferredType string, interfaceType string, moduleName string) {
func (s *bindingSuite) ThereIsABindingForAInModule(preferredType, interfaceType, moduleName string) {
s.addConfig(depinject.BindInterfaceInModule(moduleName, fullTypeName(interfaceType), fullTypeName(preferredType)))
}

Expand All @@ -147,7 +147,7 @@ func (s *bindingSuite) ModuleWantsADuck(module string) {
s.addConfig(depinject.ProvideInModule(module, ProvideModuleDuck))
}

func (s *bindingSuite) ModuleResolvesA(module string, duckType string) {
func (s *bindingSuite) ModuleResolvesA(module, duckType string) {
pond := s.resolvePond()
moduleFound := false
for _, dw := range pond.Ducks {
Expand Down
6 changes: 3 additions & 3 deletions depinject/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func invoke(ctr *container, key *moduleKey, invokers []interface{}) error {
//
// "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback")
func BindInterface(inTypeName string, outTypeName string) Config {
func BindInterface(inTypeName, outTypeName string) Config {
return containerConfig(func(ctr *container) error {
return bindInterface(ctr, inTypeName, outTypeName, "")
})
Expand All @@ -125,13 +125,13 @@ func BindInterface(inTypeName string, outTypeName string) Config {
// "moduleFoo",
// "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback")
func BindInterfaceInModule(moduleName string, inTypeName string, outTypeName string) Config {
func BindInterfaceInModule(moduleName, inTypeName, outTypeName string) Config {
return containerConfig(func(ctr *container) error {
return bindInterface(ctr, inTypeName, outTypeName, moduleName)
})
}

func bindInterface(ctr *container, inTypeName string, outTypeName string, moduleName string) error {
func bindInterface(ctr *container, inTypeName, outTypeName, moduleName string) error {
var mk *moduleKey
if moduleName != "" {
mk = &moduleKey{name: moduleName}
Expand Down
2 changes: 1 addition & 1 deletion depinject/internal/codegen/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (g *FileGen) TypeExpr(typ reflect.Type) (ast.Expr, error) {

var genericTypeNameRegex = regexp.MustCompile(`(\w+)\[(.*)]`)

func (g *FileGen) importGenericTypeParams(typeName string, pkgPath string) (newTypeName string) {
func (g *FileGen) importGenericTypeParams(typeName, pkgPath string) (newTypeName string) {
// a generic type parameter from the same package the generic type is defined won't have the
// full package name so we need to compare it with the final package part (the default import prefix)
// ex: for a/b.C in package a/b, we'll just see the type param b.C.
Expand Down
2 changes: 1 addition & 1 deletion depinject/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (f *location) Format(w fmt.State, c rune) {

const _vendor = "/vendor/"

func splitFuncName(function string) (pname string, fname string) {
func splitFuncName(function string) (pname, fname string) {
if len(function) == 0 {
return
}
Expand Down
2 changes: 1 addition & 1 deletion math/dec.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ func LegacyDecEq(t *testing.T, exp, got LegacyDec) (*testing.T, bool, string, st
return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String()
}

func LegacyDecApproxEq(t *testing.T, d1 LegacyDec, d2 LegacyDec, tol LegacyDec) (*testing.T, bool, string, string, string) {
func LegacyDecApproxEq(t *testing.T, d1, d2, tol LegacyDec) (*testing.T, bool, string, string, string) {
diff := d1.Sub(d2).Abs()
return t, diff.LTE(tol), "expected |d1 - d2| <:\t%v\ngot |d1 - d2| = \t\t%v", tol.String(), diff.String()
}
Expand Down
24 changes: 12 additions & 12 deletions math/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@ func newIntegerFromString(s string) (*big.Int, bool) {
return new(big.Int).SetString(s, 0)
}

func equal(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 0 }
func equal(i, i2 *big.Int) bool { return i.Cmp(i2) == 0 }

func gt(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == 1 }
func gt(i, i2 *big.Int) bool { return i.Cmp(i2) == 1 }

func gte(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) >= 0 }
func gte(i, i2 *big.Int) bool { return i.Cmp(i2) >= 0 }

func lt(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) == -1 }
func lt(i, i2 *big.Int) bool { return i.Cmp(i2) == -1 }

func lte(i *big.Int, i2 *big.Int) bool { return i.Cmp(i2) <= 0 }
func lte(i, i2 *big.Int) bool { return i.Cmp(i2) <= 0 }

func add(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Add(i, i2) }
func add(i, i2 *big.Int) *big.Int { return new(big.Int).Add(i, i2) }

func sub(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Sub(i, i2) }
func sub(i, i2 *big.Int) *big.Int { return new(big.Int).Sub(i, i2) }

func mul(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mul(i, i2) }
func mul(i, i2 *big.Int) *big.Int { return new(big.Int).Mul(i, i2) }

func div(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Quo(i, i2) }
func div(i, i2 *big.Int) *big.Int { return new(big.Int).Quo(i, i2) }

func mod(i *big.Int, i2 *big.Int) *big.Int { return new(big.Int).Mod(i, i2) }
func mod(i, i2 *big.Int) *big.Int { return new(big.Int).Mod(i, i2) }

func neg(i *big.Int) *big.Int { return new(big.Int).Neg(i) }

func abs(i *big.Int) *big.Int { return new(big.Int).Abs(i) }

func min(i *big.Int, i2 *big.Int) *big.Int {
func min(i, i2 *big.Int) *big.Int {
if i.Cmp(i2) == 1 {
return new(big.Int).Set(i2)
}

return new(big.Int).Set(i)
}

func max(i *big.Int, i2 *big.Int) *big.Int {
func max(i, i2 *big.Int) *big.Int {
if i.Cmp(i2) == -1 {
return new(big.Int).Set(i2)
}
Expand Down
2 changes: 1 addition & 1 deletion math/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func checkNewUint(i *big.Int) (Uint, error) {

// RelativePow raises x to the power of n, where x (and the result, z) are scaled by factor b
// for example, RelativePow(210, 2, 100) = 441 (2.1^2 = 4.41)
func RelativePow(x Uint, n Uint, b Uint) (z Uint) {
func RelativePow(x, n, b Uint) (z Uint) {
if x.IsZero() {
if n.IsZero() {
z = b // 0^0 = 1
Expand Down
2 changes: 1 addition & 1 deletion orm/internal/codegen/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (g queryProtoGen) startResponseType(format string, args ...any) {
g.startRequestResponseType("response", format, args...)
}

func (g queryProtoGen) startRequestResponseType(typ string, format string, args ...any) {
func (g queryProtoGen) startRequestResponseType(typ, format string, args ...any) {
msgTypeName := fmt.Sprintf(format, args...)
g.msgs.F("// %s is the %s/%s %s type.", msgTypeName, g.queryServiceName(), msgTypeName, typ)
g.msgs.F("message %s {", msgTypeName)
Expand Down
2 changes: 1 addition & 1 deletion orm/internal/testkv/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ type debugIterator struct {
debugger Debugger
}

func (d debugIterator) Domain() (start []byte, end []byte) {
func (d debugIterator) Domain() (start, end []byte) {
start, end = d.iterator.Domain()
d.debugger.Log(fmt.Sprintf(" DOMAIN %x -> %x", start, end))
return start, end
Expand Down
2 changes: 1 addition & 1 deletion orm/model/ormtable/unique.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ var (
// isNonTrivialUniqueKey checks if unique key fields are non-trivial, meaning that they
// don't contain the full primary key. If they contain the full primary key, then
// we can just use a regular index because there is no new unique constraint.
func isNonTrivialUniqueKey(fields []protoreflect.Name, primaryKeyFields []protoreflect.Name) bool {
func isNonTrivialUniqueKey(fields, primaryKeyFields []protoreflect.Name) bool {
have := map[protoreflect.Name]bool{}
for _, field := range fields {
have[field] = true
Expand Down
2 changes: 1 addition & 1 deletion simapp/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs []string, modulesToExport []string) (servertypes.ExportedApp, error) {
func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAddrs, modulesToExport []string) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, cmtproto.Header{Height: app.LastBlockHeight()})

Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func calculateIP(ip string, i int) (string, error) {
return ipv4.String(), nil
}

func writeFile(name string, dir string, contents []byte) error {
func writeFile(name, dir string, contents []byte) error {
file := filepath.Join(dir, name)

if err := os.MkdirAll(dir, 0o755); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion store/cachekv/bench_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func generateSequentialKeys(startKey []byte, numKeys int) [][]byte {
}

// Generate many random, unsorted keys
func generateRandomKeys(keySize int, numKeys int) [][]byte {
func generateRandomKeys(keySize, numKeys int) [][]byte {
toReturn := make([][]byte, 0, numKeys)
for i := 0; i < numKeys; i++ {
newKey := randSlice(keySize)
Expand Down
2 changes: 1 addition & 1 deletion store/cachekv/internal/memiterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func newMemIterator(start, end []byte, items BTree, ascending bool) *memIterator
return mi
}

func (mi *memIterator) Domain() (start []byte, end []byte) {
func (mi *memIterator) Domain() (start, end []byte) {
return mi.start, mi.end
}

Expand Down
2 changes: 1 addition & 1 deletion store/cachekv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (store *Store) Get(key []byte) (value []byte) {
}

// Set implements types.KVStore.
func (store *Store) Set(key []byte, value []byte) {
func (store *Store) Set(key, value []byte) {
types.AssertValidKey(key)
types.AssertValidValue(value)

Expand Down
4 changes: 2 additions & 2 deletions store/gaskv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (gs *Store) Get(key []byte) (value []byte) {
}

// Implements KVStore.
func (gs *Store) Set(key []byte, value []byte) {
func (gs *Store) Set(key, value []byte) {
types.AssertValidKey(key)
types.AssertValidValue(value)
gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc)
Expand Down Expand Up @@ -121,7 +121,7 @@ func newGasIterator(gasMeter types.GasMeter, gasConfig types.GasConfig, parent t
}

// Implements Iterator.
func (gi *gasIterator) Domain() (start []byte, end []byte) {
func (gi *gasIterator) Domain() (start, end []byte) {
return gi.parent.Domain()
}

Expand Down
2 changes: 1 addition & 1 deletion store/iavl/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func TestIAVLReverseIterator(t *testing.T) {
iavlStore.Set([]byte{0x00, 0x02}, []byte("0 2"))
iavlStore.Set([]byte{0x01}, []byte("1"))

testReverseIterator := func(t *testing.T, start []byte, end []byte, expected []string) {
testReverseIterator := func(t *testing.T, start, end []byte, expected []string) {
iter := iavlStore.ReverseIterator(start, end)
var i int
for i = 0; iter.Valid(); iter.Next() {
Expand Down
4 changes: 2 additions & 2 deletions store/listenkv/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *Store) Get(key []byte) []byte {

// Set implements the KVStore interface. It traces a write operation and
// delegates the Set call to the parent KVStore.
func (s *Store) Set(key []byte, value []byte) {
func (s *Store) Set(key, value []byte) {
types.AssertValidKey(key)
s.parent.Set(key, value)
s.listener.OnWrite(s.parentStoreKey, key, value, false)
Expand Down Expand Up @@ -87,7 +87,7 @@ func newTraceIterator(parent types.Iterator, listener *types.MemoryListener) typ
}

// Domain implements the Iterator interface.
func (li *listenIterator) Domain() (start []byte, end []byte) {
func (li *listenIterator) Domain() (start, end []byte) {
return li.parent.Domain()
}

Expand Down
4 changes: 2 additions & 2 deletions store/prefix/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewStore(parent types.KVStore, prefix []byte) Store {
}
}

func cloneAppend(bz []byte, tail []byte) (res []byte) {
func cloneAppend(bz, tail []byte) (res []byte) {
res = make([]byte, len(bz)+len(tail))
copy(res, bz)
copy(res[len(bz):], tail)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (pi *prefixIterator) Error() error {
}

// copied from github.com/cometbft/cometbft/libs/db/prefix_db.go
func stripPrefix(key []byte, prefix []byte) []byte {
func stripPrefix(key, prefix []byte) []byte {
if len(key) < len(prefix) || !bytes.Equal(key[:len(prefix)], prefix) {
panic("should not happen")
}
Expand Down
2 changes: 1 addition & 1 deletion store/prefix/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func mockStoreWithStuff() types.KVStore {
return store
}

func checkValue(t *testing.T, store types.KVStore, key []byte, expected []byte) {
func checkValue(t *testing.T, store types.KVStore, key, expected []byte) {
bz := store.Get(key)
require.Equal(t, expected, bz)
}
Expand Down
4 changes: 2 additions & 2 deletions store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func deleteKVStore(kv types.KVStore) error {
}

// we simulate move by a copy and delete
func moveKVStoreData(oldDB types.KVStore, newDB types.KVStore) error {
func moveKVStoreData(oldDB, newDB types.KVStore) error {
// we read from one and write to another
itr := oldDB.Iterator(nil, nil)
for itr.Valid() {
Expand Down Expand Up @@ -743,7 +743,7 @@ func (rs *Store) SetInitialVersion(version int64) error {
// parsePath expects a format like /<storeName>[/<subpath>]
// Must start with /, subpath may be empty
// Returns error if it doesn't start with /
func parsePath(path string) (storeName string, subpath string, err error) {
func parsePath(path string) (storeName, subpath string, err error) {
if !strings.HasPrefix(path, "/") {
return storeName, subpath, errorsmod.Wrapf(types.ErrUnknownRequest, "invalid path: %s", path)
}
Expand Down
2 changes: 1 addition & 1 deletion store/rootmulti/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ type MockListener struct {
stateCache []types.StoreKVPair
}

func (tl *MockListener) OnWrite(storeKey types.StoreKey, key []byte, value []byte, delete bool) error {
func (tl *MockListener) OnWrite(storeKey types.StoreKey, key, value []byte, delete bool) error {
tl.stateCache = append(tl.stateCache, types.StoreKVPair{
StoreKey: storeKey.Name(),
Key: key,
Expand Down
2 changes: 1 addition & 1 deletion store/snapshots/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (m *Manager) List() ([]*types.Snapshot, error) {

// LoadChunk loads a chunk into a byte slice, mirroring ABCI LoadChunk. It can be called
// concurrently with other operations. If the chunk does not exist, nil is returned.
func (m *Manager) LoadChunk(height uint64, format uint32, chunk uint32) ([]byte, error) {
func (m *Manager) LoadChunk(height uint64, format, chunk uint32) ([]byte, error) {
reader, err := m.store.LoadChunk(height, format, chunk)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 1f2875d

Please sign in to comment.