style: make lint-fix everything (#15631)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
Jacob Gadikian 2023-03-31 00:27:39 +07:00 committed by GitHub
parent d9e04c56c6
commit b009a75eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 83 additions and 43 deletions

View File

@ -53,22 +53,62 @@ issues:
max-same-issues: 10000
linters-settings:
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
# - G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
- G106 # Audit the use of ssh.InsecureIgnoreHostKey
- G107 # Url provided to HTTP request as taint input
- G108 # Profiling endpoint automatically exposed on /debug/pprof
- G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32
- G110 # Potential DoS vulnerability via decompression bomb
- G111 # Potential directory traversal
- G112 # Potential slowloris attack
- G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
- G114 # Use of net/http serve function that has no support for setting timeouts
- G201 # SQL query construction using format string
- G202 # SQL query construction using string concatenation
- G203 # Use of unescaped data in HTML templates
- G204 # Audit use of command execution
- G301 # Poor file permissions used when creating a directory
- G302 # Poor file permissions used with chmod
- G303 # Creating tempfile using a predictable path
- G304 # File path provided as taint input
- G305 # File traversal when extracting zip/tar archive
- G306 # Poor file permissions used when writing to a new file
- G307 # Deferring a method which returns an error
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
- G402 # Look for bad TLS connection settings
- G403 # Ensure minimum RSA key length of 2048 bits
- G404 # Insecure random number source (rand)
- G501 # Import blocklist: crypto/md5
- G502 # Import blocklist: crypto/des
- G503 # Import blocklist: crypto/rc4
- G504 # Import blocklist: net/http/cgi
- G505 # Import blocklist: crypto/sha1
- G601 # Implicit memory aliasing of items from a range statement
misspell:
# Correct spellings using locale preferences for US or UK.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
# Default is to use a neutral variety of English.
locale: US
gofumpt:
# Choose whether to use the extra rules.
# Default: false
extra-rules: true
dogsled:
max-blank-identifiers: 5
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: true
require-specific: false
gosimple:
checks: ["all"]
gocritic:
disabled-checks:
- regexpMust
- appendAssign

View File

@ -861,7 +861,7 @@ func (app *BaseApp) PrepareProposalVerifyTx(tx sdk.Tx) ([]byte, error) {
return nil, err
}
_, _, _, _, err = app.runTx(runTxPrepareProposal, bz)
_, _, _, _, err = app.runTx(runTxPrepareProposal, bz)
if err != nil {
return nil, err
}
@ -880,7 +880,7 @@ func (app *BaseApp) ProcessProposalVerifyTx(txBz []byte) (sdk.Tx, error) {
return nil, err
}
_, _, _, _, err = app.runTx(runTxProcessProposal, txBz)
_, _, _, _, err = app.runTx(runTxProcessProposal, txBz)
if err != nil {
return nil, err
}

View File

@ -132,7 +132,7 @@ func (appOptions AppOptions) EnhanceRootCommandWithBuilder(rootCmd *cobra.Comman
enhanceMsg := func(cmd *cobra.Command, modOpts *autocliv1.ModuleOptions, moduleName string) error {
txCmdDesc := modOpts.Tx
if txCmdDesc != nil {
subCmd := topLevelCmd(moduleName, fmt.Sprintf("Transations commands for the %s module", moduleName))
subCmd := topLevelCmd(moduleName, fmt.Sprintf("Transactions commands for the %s module", moduleName))
err := builder.AddQueryServiceCommands(cmd, txCmdDesc)
if err != nil {
return err

View File

@ -19,7 +19,7 @@ func (b *Builder) BuildMsgCommand(moduleOptions map[string]*autocliv1.ModuleOpti
enhanceMsg := func(cmd *cobra.Command, modOpts *autocliv1.ModuleOptions, moduleName string) error {
txCmdDesc := modOpts.Tx
if txCmdDesc != nil {
subCmd := topLevelCmd(moduleName, fmt.Sprintf("Transations commands for the %s module", moduleName))
subCmd := topLevelCmd(moduleName, fmt.Sprintf("Transactions commands for the %s module", moduleName))
err := b.AddMsgServiceCommands(subCmd, txCmdDesc)
if err != nil {
return err

View File

@ -17,7 +17,7 @@ import (
)
var buildModuleMsgCommand = func(moduleName string, b *Builder) (*cobra.Command, error) {
cmd := topLevelCmd(moduleName, fmt.Sprintf("Transations commands for the %s module", moduleName))
cmd := topLevelCmd(moduleName, fmt.Sprintf("Transactions commands for the %s module", moduleName))
err := b.AddMsgServiceCommands(cmd, testCmdMsgDesc)
return cmd, err
@ -281,7 +281,7 @@ func TestErrorBuildMsgCommand(t *testing.T) {
func TestNotFoundErrorsMsg(t *testing.T) {
b := &Builder{}
buildModuleMsgCommand := func(moduleName string, cmdDescriptor *autocliv1.ServiceCommandDescriptor) (*cobra.Command, error) {
cmd := topLevelCmd(moduleName, fmt.Sprintf("Transations commands for the %s module", moduleName))
cmd := topLevelCmd(moduleName, fmt.Sprintf("Transactions commands for the %s module", moduleName))
err := b.AddMsgServiceCommands(cmd, cmdDescriptor)
return cmd, err
@ -331,7 +331,7 @@ func TestEnhanceMessageCommand(t *testing.T) {
enhanceMsg := func(cmd *cobra.Command, modOpts *autocliv1.ModuleOptions, moduleName string) error {
txCmdDesc := modOpts.Tx
if txCmdDesc != nil {
subCmd := topLevelCmd(moduleName, fmt.Sprintf("Transations commands for the %s module", moduleName))
subCmd := topLevelCmd(moduleName, fmt.Sprintf("Transactions commands for the %s module", moduleName))
err := b.AddMsgServiceCommands(cmd, txCmdDesc)
if err != nil {
return err

View File

@ -1,4 +1,4 @@
Transations commands for the test module
Transactions commands for the test module
Usage:
test [flags]

View File

@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
)
// TestKeyCodec asserts the correct behaviour of a KeyCodec over the type T.
// TestKeyCodec asserts the correct behavior of a KeyCodec over the type T.
func TestKeyCodec[T any](t *testing.T, keyCodec codec.KeyCodec[T], key T) {
buffer := make([]byte, keyCodec.Size(key))
written, err := keyCodec.Encode(buffer, key)
@ -43,7 +43,7 @@ func TestKeyCodec[T any](t *testing.T, keyCodec codec.KeyCodec[T], key T) {
require.Equal(t, key, decoded, "json encoding and decoding did not produce the same results")
}
// TestValueCodec asserts the correct behaviour of a ValueCodec over the type T.
// TestValueCodec asserts the correct behavior of a ValueCodec over the type T.
func TestValueCodec[T any](t *testing.T, encoder codec.ValueCodec[T], value T) {
encodedValue, err := encoder.Encode(value)
require.NoError(t, err)

View File

@ -40,10 +40,10 @@ type IndexedMap[PrimaryKey, Value any, Idx Indexes[PrimaryKey, Value]] struct {
}
// NewIndexedMap instantiates a new IndexedMap. Accepts a SchemaBuilder, a Prefix,
// a humanised name that defines the name of the collection, the primary key codec
// a humanized name that defines the name of the collection, the primary key codec
// which is basically what IndexedMap uses to encode the primary key to bytes,
// the value codec which is what the IndexedMap uses to encode the value.
// Then it expects the initialised indexes.
// Then it expects the initialized indexes.
func NewIndexedMap[PrimaryKey, Value any, Idx Indexes[PrimaryKey, Value]](
schema *SchemaBuilder,
prefix Prefix,
@ -105,7 +105,7 @@ func (m *IndexedMap[PrimaryKey, Value, Idx]) Set(ctx context.Context, pk Primary
func (m *IndexedMap[PrimaryKey, Value, Idx]) Remove(ctx context.Context, pk PrimaryKey) error {
oldValue, err := m.m.Get(ctx, pk)
if err != nil {
// TODO retain Map behaviour? which does not error in case we remove a non-existing object
// TODO retain Map behavior? which does not error in case we remove a non-existing object
return err
}

View File

@ -42,7 +42,7 @@ type GenericMultiIndex[ReferencingKey, ReferencedKey, PrimaryKey, Value any] str
}
// NewGenericMultiIndex instantiates a GenericMultiIndex, given
// schema, Prefix, humanised name, the key codec used to encode the referencing key
// schema, Prefix, humanized name, the key codec used to encode the referencing key
// to bytes, the key codec used to encode the referenced key to bytes and a function
// which given the primary key and a value of an object being saved or removed in IndexedMap
// returns all the possible IndexReference of that object.

View File

@ -12,7 +12,7 @@ const DefaultSequenceStart uint64 = 1
type Sequence Item[uint64]
// NewSequence instantiates a new sequence given
// a Schema, a Prefix and humanised name for the sequence.
// a Schema, a Prefix and humanized name for the sequence.
func NewSequence(schema *SchemaBuilder, prefix Prefix, name string) Sequence {
return (Sequence)(NewItem(schema, prefix, name, Uint64Value))
}

View File

@ -20,6 +20,6 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
var priv *cryptotypes.PrivKey
registry.RegisterInterface("cosmos.crypto.PrivKey", priv)
registry.RegisterImplementations(priv, &secp256k1.PrivKey{})
registry.RegisterImplementations(priv, &ed25519.PrivKey{}) //nolint
registry.RegisterImplementations(priv, &ed25519.PrivKey{})
secp256r1.RegisterInterfaces(registry)
}

View File

@ -66,12 +66,12 @@ func (s *abciTestSuite) TestABCInfo() {
},
// This is hard to test because of attached stacktrace. This
// case is tested in an another test.
//"wrapped stdlib is a full message in debug mode": {
// "wrapped stdlib is a full message in debug mode": {
// err: Wrap(io.EOF, "cannot read file"),
// debug: true,
// wantLog: "cannot read file: EOF",
// wantCode: 1,
//},
// },
"custom error": {
err: customErr{},
debug: false,

View File

@ -21,7 +21,7 @@ type FilterFunc func(key, level string) bool
// Example:
// ParseLogLevel("consensus:debug,mempool:debug,*:error")
//
// This function attemps to keep the same behavior as the CometBFT ParseLogLevel
// This function attempts to keep the same behavior as the CometBFT ParseLogLevel
// However the level `none` is replaced by `disabled`.
func ParseLogLevel(levelStr string) (FilterFunc, error) {
if levelStr == "" {

View File

@ -98,7 +98,7 @@ func (s *decimalInternalTestSuite) TestDecMarshalJSON() {
return
}
if !tt.wantErr {
s.Require().Equal(tt.want, string(got), "incorrect marshalled value")
s.Require().Equal(tt.want, string(got), "incorrect marshaled value")
unmarshalledDec := LegacyNewDec(0)
err := unmarshalledDec.UnmarshalJSON(got)
s.Require().NoError(err)

View File

@ -51,7 +51,7 @@ func (app *SimApp) ExportAppStateAndValidators(forZeroHeight bool, jailAllowedAd
// prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated
//
// in favour of export at a block height
// in favor of export at a block height
func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false

View File

@ -1104,7 +1104,7 @@ type storeParams struct {
initialVersion uint64
}
func newStoreParams(key types.StoreKey, db dbm.DB, typ types.StoreType, initialVersion uint64) storeParams { // nolint
func newStoreParams(key types.StoreKey, db dbm.DB, typ types.StoreType, initialVersion uint64) storeParams {
return storeParams{
key: key,
db: db,

View File

@ -163,7 +163,7 @@ func (g *infiniteGasMeter) GasConsumed() Gas {
}
// GasConsumedToLimit returns the gas consumed from the GasMeter since the gas is not confined to a limit.
// NOTE: This behaviour is only called when recovering from panic when BlockGasMeter consumes gas past the limit.
// NOTE: This behavior is only called when recovering from panic when BlockGasMeter consumes gas past the limit.
func (g *infiniteGasMeter) GasConsumedToLimit() Gas {
return g.consumed
}

View File

@ -61,7 +61,7 @@ func NewSmtCommitmentOp(key []byte, proof *ics23.CommitmentProof) CommitmentOp {
}
// CommitmentOpDecoder takes a merkle.ProofOp and attempts to decode it into a CommitmentOp ProofOperator
// The proofOp.Data is just a marshalled CommitmentProof. The Key of the CommitmentOp is extracted
// The proofOp.Data is just a marshaled CommitmentProof. The Key of the CommitmentOp is extracted
// from the unmarshalled proof.
func CommitmentOpDecoder(pop cmtprotocrypto.ProofOp) (merkle.ProofOperator, error) {
var spec *ics23.ProofSpec

View File

@ -93,7 +93,7 @@ func (s *E2ETestSuite) TestModuleVersionsCLI() {
}
jsonVM, _ := clientCtx.Codec.MarshalJSON(&pm)
expectedRes := string(jsonVM)
// append new line to match behaviour of PrintProto
// append new line to match behavior of PrintProto
expectedRes += "\n"
// get actual module versions list response from cli

View File

@ -408,7 +408,7 @@ func TestAminoJSON_LegacyParity(t *testing.T) {
// represent the array as nil, and a subsequent marshal to JSON represent the array as null instead of empty.
roundTripUnequal bool
// pulsar does not support marshalling a math.Dec as anything except a string. Therefore, we cannot unmarshal
// pulsar does not support marshaling a math.Dec as anything except a string. Therefore, we cannot unmarshal
// a pulsar encoded Math.dec (the string representation of a Decimal) into a gogo Math.dec (expecting an int64).
protoUnmarshalFails bool
}{

View File

@ -297,7 +297,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
// slash validator again
// all originally bonded stake has been slashed, so this will have no effect
// on the unbonding delegation, but it will slash stake bonded since the infraction
// this may not be the desirable behaviour, ref https://github.com/cosmos/cosmos-sdk/issues/1440
// this may not be the desirable behavior, ref https://github.com/cosmos/cosmos-sdk/issues/1440
ctx = ctx.WithBlockHeight(13)
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction)
@ -323,7 +323,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) {
// slash validator again
// all originally bonded stake has been slashed, so this will have no effect
// on the unbonding delegation, but it will slash stake bonded since the infraction
// this may not be the desirable behaviour, ref https://github.com/cosmos/cosmos-sdk/issues/1440
// this may not be the desirable behavior, ref https://github.com/cosmos/cosmos-sdk/issues/1440
ctx = ctx.WithBlockHeight(13)
app.StakingKeeper.Slash(ctx, consAddr, 9, 10, fraction)

View File

@ -133,7 +133,7 @@ var (
ErrOffline = RegisterError(1, "cannot query endpoint in offline mode", false, "returned when querying an online endpoint in offline mode")
// ErrNetworkNotSupported is returned when there is an attempt to query a network which is not supported
ErrNetworkNotSupported = RegisterError(2, "network is not supported", false, "returned when querying a non supported network")
// ErrCodec is returned when there's an error while marshalling or unmarshalling data
// ErrCodec is returned when there's an error while marshaling or unmarshalling data
ErrCodec = RegisterError(3, "encode/decode error", true, "returned when there are errors encoding or decoding information to and from the node")
// ErrInvalidOperation is returned when the operation supplied to rosetta is not a valid one
ErrInvalidOperation = RegisterError(4, "invalid operation", false, "returned when the operation is not valid")

View File

@ -153,7 +153,7 @@ func indirect(ptr interface{}) interface{} {
}
func TestGetSubspaces(t *testing.T) {
_, _, _, _, keeper := testComponents()
_, _, _, _, keeper := testComponents()
table := types.NewKeyTable(
types.NewParamSetPair([]byte("string"), "", validateNoOp),

View File

@ -657,11 +657,11 @@ func TestRejectUnknownFieldsFlat(t *testing.T) {
func TestPackedEncoding(t *testing.T) {
data := &testpb.TestRepeatedUints{Nums: []uint64{12, 13}}
marshalled, err := proto.Marshal(data)
marshaled, err := proto.Marshal(data)
require.NoError(t, err)
unmarshalled := data.ProtoReflect().Descriptor()
_, err = decode.RejectUnknownFields(marshalled, unmarshalled, false, ProtoResolver)
_, err = decode.RejectUnknownFields(marshaled, unmarshalled, false, ProtoResolver)
require.NoError(t, err)
}

View File

@ -46,7 +46,7 @@ func (vr intValueRenderer) Parse(_ context.Context, screens []Screen) (protorefl
if err != nil {
return nilValue, err
}
return protoreflect.ValueOfUint32(uint32(value)), nil //nolint:gosec
return protoreflect.ValueOfUint32(uint32(value)), nil
case protoreflect.Uint64Kind:
value, err := strconv.ParseUint(parsedInt, 10, 64)
@ -60,7 +60,7 @@ func (vr intValueRenderer) Parse(_ context.Context, screens []Screen) (protorefl
if err != nil {
return nilValue, err
}
return protoreflect.ValueOfInt32(int32(value)), nil //nolint:gosec
return protoreflect.ValueOfInt32(int32(value)), nil
case protoreflect.Int64Kind:
value, err := strconv.ParseInt(parsedInt, 10, 64)

View File

@ -117,7 +117,7 @@ specified here https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor/README.
This will allow a properly configured cosmsod daemon to auto-download new binaries and auto-upgrade.
As noted there, this is intended more for full nodes than validators.
# Cancelling Upgrades
# Canceling Upgrades
There are two ways to cancel a planned upgrade - with on-chain governance or off-chain social consensus.
For the first one, there is a CancelSoftwareUpgrade proposal type, which can be voted on and will

View File

@ -35,7 +35,7 @@ type Keeper struct {
upgradeHandlers map[string]types.UpgradeHandler // map of plan name to upgrade handler
versionSetter xp.ProtocolVersionSetter // implements setting the protocol version field on BaseApp
downgradeVerified bool // tells if we've already sanity checked that this binary version isn't being used against an old state.
authority string // the address capable of executing and cancelling an upgrade. Usually the gov module account
authority string // the address capable of executing and canceling an upgrade. Usually the gov module account
initVersionMap module.VersionMap // the module version map at init genesis
}

View File

@ -94,7 +94,7 @@ func (s *KeeperTestSuite) TestCancelUpgrade() {
"expected gov account as only signer for proposal message",
},
{
"upgrade cancelled successfully",
"upgrade canceled successfully",
&types.MsgCancelUpgrade{
Authority: govAccAddr,
},