Skip to content

Commit

Permalink
ci: enable revive (#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jul 30, 2022
1 parent ed8d270 commit b75f6be
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ linters:
enable:
- gofumpt
- misspell
- revive
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func New(
skipUpgradeHeights map[int64]bool,
homePath string,
invCheckPeriod uint,
encodingConfig encoding.EncodingConfig,
encodingConfig encoding.Config,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
Expand Down
10 changes: 5 additions & 5 deletions app/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ type ModuleRegister interface {
RegisterInterfaces(codectypes.InterfaceRegistry)
}

// EncodingConfig specifies the concrete encoding types to use for a given app.
// Config specifies the concrete encoding types to use for a given app.
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
type Config struct {
InterfaceRegistry codectypes.InterfaceRegistry
Codec codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}

// MakeEncodingConfig creates an encoding config for the app.
func MakeEncodingConfig(regs ...ModuleRegister) EncodingConfig {
// MakeConfig creates an encoding config for the app.
func MakeConfig(regs ...ModuleRegister) Config {
// create the codec
amino := codec.NewLegacyAmino()
interfaceRegistry := codectypes.NewInterfaceRegistry()
Expand All @@ -42,7 +42,7 @@ func MakeEncodingConfig(regs ...ModuleRegister) EncodingConfig {
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)

return EncodingConfig{
return Config{
InterfaceRegistry: interfaceRegistry,
Codec: marshaler,
TxConfig: txCfg,
Expand Down
4 changes: 2 additions & 2 deletions app/test/block_size_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type IntegrationTestSuite struct {
suite.Suite

cfg cosmosnet.Config
encCfg encoding.EncodingConfig
encCfg encoding.Config
network *cosmosnet.Network
kr keyring.Keyring
accounts []string
Expand Down Expand Up @@ -60,7 +60,7 @@ func (s *IntegrationTestSuite) SetupSuite() {

s.network = net
s.kr = net.Validators[0].ClientCtx.Keyring
s.encCfg = encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
s.encCfg = encoding.MakeConfig(app.ModuleEncodingRegisters...)

_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion app/test/prepare_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func TestPrepareProposal(t *testing.T) {
signer := testutil.GenerateKeyringSigner(t, testAccName)

encCfg := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)

testApp := testutil.SetupTestAppWithGenesisValSet(t)

Expand Down
2 changes: 1 addition & 1 deletion app/test/process_proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestMessageInclusionCheck(t *testing.T) {

testApp := testutil.SetupTestAppWithGenesisValSet(t)

encConf := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encConf := encoding.MakeConfig(app.ModuleEncodingRegisters...)

firstValidPFD, msg1 := genRandMsgPayForData(t, signer, 8)
secondValidPFD, msg2 := genRandMsgPayForData(t, signer, 8)
Expand Down
2 changes: 1 addition & 1 deletion app/test/split_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestSplitShares(t *testing.T) {
encCfg := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)

type test struct {
squareSize uint64
Expand Down
8 changes: 4 additions & 4 deletions cmd/celestia-appd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const EnvPrefix = "CELESTIA"
// NewRootCmd creates a new root command for celestia-appd. It is called once in the
// main function.
func NewRootCmd() *cobra.Command {
encodingConfig := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encodingConfig := encoding.MakeConfig(app.ModuleEncodingRegisters...)

cfg := sdk.GetConfig()
cfg.SetBech32PrefixForAccount(app.Bech32PrefixAccAddr, app.Bech32PrefixAccPub)
Expand Down Expand Up @@ -117,7 +117,7 @@ func initAppConfig() (string, interface{}) {
return CelestiaAppTemplate, CelestiaAppCfg
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig encoding.EncodingConfig) {
func initRootCmd(rootCmd *cobra.Command, encodingConfig encoding.Config) {
cfg := sdk.GetConfig()
cfg.Seal()

Expand Down Expand Up @@ -222,7 +222,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...), // Ideally, we would reuse the one created by NewRootCmd.
encoding.MakeConfig(app.ModuleEncodingRegisters...), // Ideally, we would reuse the one created by NewRootCmd.
appOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
Expand All @@ -240,7 +240,7 @@ func createAppAndExport(
logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailWhiteList []string,
appOpts servertypes.AppOptions,
) (servertypes.ExportedApp, error) {
encCfg := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...) // Ideally, we would reuse the one created by NewRootCmd.
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) // Ideally, we would reuse the one created by NewRootCmd.
encCfg.Codec = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var capp *app.App
if height != -1 {
Expand Down
2 changes: 1 addition & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func GRPCConn(net *network.Network) error {
// genesis and single validator. All other parameters are inherited from
// cosmos-sdk/testutil/network.DefaultConfig
func DefaultConfig() network.Config {
encCfg := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)

return network.Config{
Codec: encCfg.Codec,
Expand Down
4 changes: 2 additions & 2 deletions testutil/test_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func SetupTestAppWithGenesisValSet(t *testing.T) *app.App {
db := dbm.NewMemDB()
skipUpgradeHeights := make(map[int64]bool)

encCfg := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)

testApp := app.New(
log.NewNopLogger(), db, nil, true, skipUpgradeHeights,
Expand Down Expand Up @@ -293,7 +293,7 @@ func genesisStateWithValSet(t *testing.T,
// GenerateKeyringSigner creates a types.KeyringSigner with keys generated for
// the provided accounts
func GenerateKeyringSigner(t *testing.T, acct string) *types.KeyringSigner {
encCfg := encoding.MakeEncodingConfig(app.ModuleEncodingRegisters...)
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
kr := generateKeyring(t, encCfg.Codec, acct)
return types.NewKeyringSigner(kr, acct, testChainID)
}
Expand Down
4 changes: 2 additions & 2 deletions x/payment/types/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type KeyringSigner struct {
accountNumber uint64
sequence uint64
chainID string
encCfg encoding.EncodingConfig
encCfg encoding.Config

sync.RWMutex
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func BroadcastTx(ctx context.Context, conn *grpc.ClientConn, mode tx.BroadcastMo
}

// QueryAccount fetches the account number and sequence number from the celestia-app node.
func QueryAccount(ctx context.Context, conn *grpc.ClientConn, encCfg encoding.EncodingConfig, address string) (accNum uint64, seqNum uint64, err error) {
func QueryAccount(ctx context.Context, conn *grpc.ClientConn, encCfg encoding.Config, address string) (accNum uint64, seqNum uint64, err error) {
qclient := authtypes.NewQueryClient(conn)
resp, err := qclient.Account(
ctx,
Expand Down
4 changes: 2 additions & 2 deletions x/payment/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (localEncoder) RegisterInterfaces(r codectypes.InterfaceRegistry) {
// makePaymentEncodingConfig uses the payment modules RegisterInterfaces
// function to create an encoding config for the payment module. This is useful
// so that we don't have to import the app package.
func makePaymentEncodingConfig() encoding.EncodingConfig {
func makePaymentEncodingConfig() encoding.Config {
e := localEncoder{}
return encoding.MakeEncodingConfig(e)
return encoding.MakeConfig(e)
}
3 changes: 1 addition & 2 deletions x/payment/types/payfordata.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,8 @@ func nextLowestPowerOf2(v uint64) uint64 {
func powerOf2(v uint64) bool {
if v&(v-1) == 0 && v != 0 {
return true
} else {
return false
}
return false
}

// DelimLen calculates the length of the delimiter for a given message size
Expand Down

0 comments on commit b75f6be

Please sign in to comment.