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: apply any / all automated lint fixes #15644

Merged
merged 15 commits into from
Mar 31, 2023
1 change: 1 addition & 0 deletions client/v2/autocli/flag/coin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flag

import (
"context"

basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1"
"cosmossdk.io/core/coins"
"google.golang.org/protobuf/reflect/protoreflect"
Expand Down
1 change: 1 addition & 0 deletions client/v2/autocli/flag/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package flag

import (
"context"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
cosmos_proto "github.com/cosmos/cosmos-proto"
"github.com/spf13/pflag"
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/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 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
2 changes: 1 addition & 1 deletion testutil/sims/simulation_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestDiffKVStores(t *testing.T) {

// Same keys, different value. Comparisons will be nil as prefixes are skipped.
prefix := []byte("prefix:")
k1Prefixed := append(prefix, k1...) //nolint:gocritic // append is fine here
k1Prefixed := append(prefix, k1...)
store1.Set(k1Prefixed, v1)
store2.Set(k1Prefixed, v2)
checkDiffResults(t, store1, store2)
Expand Down
2 changes: 1 addition & 1 deletion tools/rosetta/lib/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Server struct {

func (h Server) Start() error {
h.logger.Info(fmt.Sprintf("Rosetta server listening on add %s", h.addr))
return http.ListenAndServe(h.addr, h.h) //nolint:gosec // users are recommended to operate a proxy in front of this server
return http.ListenAndServe(h.addr, h.h) //nolint:gosec // users are recommended to operate a proxy in front of this server

Check failure

Code scanning / gosec

Use of net/http serve function that has no support for setting timeouts

Use of net/http serve function that has no support for setting timeouts
}

func NewServer(settings Settings) (Server, error) {
Expand Down
2 changes: 1 addition & 1 deletion x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (ak AccountKeeper) decodeAccount(bz []byte) sdk.AccountI {
}

// MarshalAccount protobuf serializes an Account interface
func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) { //nolint:interfacer
func (ak AccountKeeper) MarshalAccount(accountI sdk.AccountI) ([]byte, error) {
return ak.cdc.MarshalInterface(accountI)
}

Expand Down
2 changes: 1 addition & 1 deletion x/auth/simulation/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
const (
DefaultWeightMsgUpdateParams int = 100

OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec
OpWeightMsgUpdateParams = "op_weight_msg_update_params"
)

// ProposalMsgs defines the module weighted proposals' contents
Expand Down
4 changes: 1 addition & 3 deletions x/auth/types/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ var (
_ sdk.ModuleAccountI = (*ModuleAccount)(nil)
)

// NewBaseAccount creates a new BaseAccount object
//
//nolint:interfacer
// NewBaseAccount creates a new BaseAccount object.
func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount {
acc := &BaseAccount{
Address: address.String(),
Expand Down
1 change: 0 additions & 1 deletion x/auth/types/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func NewBaseAccountWithPubKey(pubkey cryptotypes.PubKey) (*BaseAccount, error) {
return baseAccount, nil
}

//nolint:gosec // this isn't an hardcoded credential
const ModuleCredentialType = "ModuleCredential"

var _ cryptotypes.PubKey = &ModuleCredential{}
Expand Down
6 changes: 0 additions & 6 deletions x/auth/vesting/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ var (
)

// NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount.
//
//nolint:interfacer
func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins, endTime int64, delayed bool) *MsgCreateVestingAccount {
return &MsgCreateVestingAccount{
FromAddress: fromAddr.String(),
Expand Down Expand Up @@ -70,8 +68,6 @@ func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress {
}

// NewMsgCreatePermanentLockedAccount returns a reference to a new MsgCreatePermanentLockedAccount.
//
//nolint:interfacer
func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgCreatePermanentLockedAccount {
return &MsgCreatePermanentLockedAccount{
FromAddress: fromAddr.String(),
Expand Down Expand Up @@ -113,8 +109,6 @@ func (msg MsgCreatePermanentLockedAccount) GetSigners() []sdk.AccAddress {
}

// NewMsgCreatePeriodicVestingAccount returns a reference to a new MsgCreatePeriodicVestingAccount.
//
//nolint:interfacer
func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount {
return &MsgCreatePeriodicVestingAccount{
FromAddress: fromAddr.String(),
Expand Down
6 changes: 0 additions & 6 deletions x/authz/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ var (
)

// NewMsgGrant creates a new MsgGrant
//
//nolint:interfacer
func NewMsgGrant(granter, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) {
m := &MsgGrant{
Granter: granter.String(),
Expand Down Expand Up @@ -109,8 +107,6 @@ func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error {
}

// NewMsgRevoke creates a new MsgRevoke
//
//nolint:interfacer
func NewMsgRevoke(granter, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke {
return MsgRevoke{
Granter: granter.String(),
Expand Down Expand Up @@ -153,8 +149,6 @@ func (msg MsgRevoke) GetSignBytes() []byte {
}

// NewMsgExec creates a new MsgExecAuthorized
//
//nolint:interfacer
func NewMsgExec(grantee sdk.AccAddress, msgs []sdk.Msg) MsgExec {
msgsAny := make([]*cdctypes.Any, len(msgs))
for i, msg := range msgs {
Expand Down
6 changes: 3 additions & 3 deletions x/authz/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ var (

// Simulation operation weights constants
const (
OpWeightMsgGrant = "op_weight_msg_grant" //nolint:gosec
OpWeightRevoke = "op_weight_msg_revoke" //nolint:gosec
OpWeightExec = "op_weight_msg_execute" //nolint:gosec
OpWeightMsgGrant = "op_weight_msg_grant"
OpWeightRevoke = "op_weight_msg_revoke"
OpWeightExec = "op_weight_msg_execute"
)

// authz operations weights
Expand Down
2 changes: 1 addition & 1 deletion x/bank/migrations/v3/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestMigrateDenomMetaData(t *testing.T) {
newKey := denomMetadataIter.Key()

// make sure old entry is deleted
oldKey := append(newKey, newKey[0:]...) //nolint:gocritic // append is ok here
oldKey := append(newKey, newKey[0:]...)
bz := denomMetadataStore.Get(oldKey)
require.Nil(t, bz)

Expand Down
8 changes: 4 additions & 4 deletions x/bank/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (

// Simulation operation weights constants
const (
OpWeightMsgSend = "op_weight_msg_send" //nolint:gosec
OpWeightMsgMultiSend = "op_weight_msg_multisend" //nolint:gosec
DefaultWeightMsgSend = 100 // from simappparams.DefaultWeightMsgSend
DefaultWeightMsgMultiSend = 10 // from simappparams.DefaultWeightMsgMultiSend
OpWeightMsgSend = "op_weight_msg_send"
OpWeightMsgMultiSend = "op_weight_msg_multisend"
DefaultWeightMsgSend = 100 // from simappparams.DefaultWeightMsgSend
DefaultWeightMsgMultiSend = 10 // from simappparams.DefaultWeightMsgMultiSend
)

// WeightedOperations returns all the operations from the module with their respective weights
Expand Down
2 changes: 1 addition & 1 deletion x/bank/simulation/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
const (
DefaultWeightMsgUpdateParams int = 100

OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec
OpWeightMsgUpdateParams = "op_weight_msg_update_params"
)

// ProposalMsgs defines the module weighted proposals' contents
Expand Down
6 changes: 1 addition & 5 deletions x/bank/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (

// NewMsgSend - construct a msg to send coins from one account to another.
//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1

//nolint:interfacer

func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgSend {
return &MsgSend{FromAddress: fromAddr.String(), ToAddress: toAddr.String(), Amount: amount}
}
Expand Down Expand Up @@ -116,8 +116,6 @@ func (in Input) ValidateBasic() error {
}

// NewInput - create a transaction input, used with MsgMultiSend
//
//nolint:interfacer
func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input {
return Input{
Address: addr.String(),
Expand All @@ -143,8 +141,6 @@ func (out Output) ValidateBasic() error {
}

// NewOutput - create a transaction output, used with MsgMultiSend
//
//nolint:interfacer
func NewOutput(addr sdk.AccAddress, coins sdk.Coins) Output {
return Output{
Address: addr.String(),
Expand Down
10 changes: 0 additions & 10 deletions x/bank/types/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,28 @@ const (
)

// NewQueryBalanceRequest creates a new instance of QueryBalanceRequest.
//
//nolint:interfacer
func NewQueryBalanceRequest(addr sdk.AccAddress, denom string) *QueryBalanceRequest {
return &QueryBalanceRequest{Address: addr.String(), Denom: denom}
}

// NewQueryAllBalancesRequest creates a new instance of QueryAllBalancesRequest.
//
//nolint:interfacer
func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest, resolveDenom bool) *QueryAllBalancesRequest {
return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req, ResolveDenom: resolveDenom}
}

// NewQuerySpendableBalancesRequest creates a new instance of a
// QuerySpendableBalancesRequest.
//
//nolint:interfacer
func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest {
return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req}
}

// NewQuerySpendableBalanceByDenomRequest creates a new instance of a
// QuerySpendableBalanceByDenomRequest.
//
//nolint:interfacer
func NewQuerySpendableBalanceByDenomRequest(addr sdk.AccAddress, denom string) *QuerySpendableBalanceByDenomRequest {
return &QuerySpendableBalanceByDenomRequest{Address: addr.String(), Denom: denom}
}

// QueryTotalSupplyParams defines the params for the following queries:
//
// - 'custom/bank/totalSupply'
type QueryTotalSupplyParams struct {
Page, Limit int
Expand All @@ -56,7 +47,6 @@ func NewQueryTotalSupplyParams(page, limit int) QueryTotalSupplyParams {
}

// QuerySupplyOfParams defines the params for the following queries:
//
// - 'custom/bank/totalSupplyOf'
type QuerySupplyOfParams struct {
Denom string
Expand Down
2 changes: 0 additions & 2 deletions x/crisis/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ var (
)

// NewMsgVerifyInvariant creates a new MsgVerifyInvariant object
//
//nolint:interfacer
func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) *MsgVerifyInvariant {
return &MsgVerifyInvariant{
Sender: sender.String(),
Expand Down
8 changes: 4 additions & 4 deletions x/distribution/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (

// Simulation operation weights constants
const (
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" //nolint:gosec
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward" //nolint:gosec
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission" //nolint:gosec
OpWeightMsgFundCommunityPool = "op_weight_msg_fund_community_pool" //nolint:gosec
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address"
OpWeightMsgWithdrawDelegationReward = "op_weight_msg_withdraw_delegation_reward"
OpWeightMsgWithdrawValidatorCommission = "op_weight_msg_withdraw_validator_commission"
OpWeightMsgFundCommunityPool = "op_weight_msg_fund_community_pool"

DefaultWeightMsgSetWithdrawAddress int = 50
DefaultWeightMsgWithdrawDelegationReward int = 50
Expand Down
2 changes: 1 addition & 1 deletion x/distribution/simulation/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
const (
DefaultWeightMsgUpdateParams int = 50

OpWeightMsgUpdateParams = "op_weight_msg_update_params" //nolint:gosec
OpWeightMsgUpdateParams = "op_weight_msg_update_params"
)

// ProposalMsgs defines the module weighted proposals' contents
Expand Down
1 change: 0 additions & 1 deletion x/distribution/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

//nolint:interfacer
func NewGenesisState(
params Params, fp FeePool, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress, r []ValidatorOutstandingRewardsRecord,
acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord,
Expand Down
2 changes: 0 additions & 2 deletions x/distribution/types/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ func (res QueryDelegatorTotalRewardsResponse) String() string {
}

// NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
//
//nolint:interfacer
func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward {
return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward}
}
2 changes: 0 additions & 2 deletions x/evidence/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ var (
)

// NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter.
//
//nolint:interfacer
func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (*MsgSubmitEvidence, error) {
msg, ok := evi.(proto.Message)
if !ok {
Expand Down
2 changes: 0 additions & 2 deletions x/feegrant/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
var _ types.UnpackInterfacesMessage = &Grant{}

// NewGrant creates a new FeeAllowanceGrant.
//
//nolint:interfacer
func NewGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (Grant, error) {
msg, ok := feeAllowance.(proto.Message)
if !ok {
Expand Down
4 changes: 1 addition & 3 deletions x/feegrant/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ var (
)

// NewMsgGrantAllowance creates a new MsgGrantAllowance.
//
//nolint:interfacer
func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantAllowance, error) {
msg, ok := feeAllowance.(proto.Message)
if !ok {
Expand Down Expand Up @@ -74,7 +72,7 @@ func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error
// NewMsgRevokeAllowance returns a message to revoke a fee allowance for a given
// granter and grantee
//
//nolint:interfacer

func NewMsgRevokeAllowance(granter, grantee sdk.AccAddress) MsgRevokeAllowance {
return MsgRevokeAllowance{Granter: granter.String(), Grantee: grantee.String()}
}
Expand Down
2 changes: 0 additions & 2 deletions x/gov/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ var (
)

// Simulation operation weights constants
//
//nolint:gosec // these are not hard-coded credentials.
const (
OpWeightMsgDeposit = "op_weight_msg_deposit"
OpWeightMsgVote = "op_weight_msg_vote"
Expand Down
2 changes: 0 additions & 2 deletions x/gov/types/v1/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
)

// NewDeposit creates a new Deposit instance
//
//nolint:interfacer
func NewDeposit(proposalID uint64, depositor sdk.AccAddress, amount sdk.Coins) Deposit {
return Deposit{proposalID, depositor.String(), amount}
}
Expand Down
Loading