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

lint sdk main 48 #15528

Closed
wants to merge 20 commits into from
Closed

lint sdk main 48 #15528

wants to merge 20 commits into from

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Mar 23, 2023

  • lint if-return lints
  • redefines-builtin-id
  • redefines-builtin-id

Description

Updated linting to match updated go and updated linters. WIP.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@github-actions github-actions bot added the C:x/distribution distribution module related label Mar 23, 2023
@github-actions github-actions bot added C:Cosmovisor Issues and PR related to Cosmovisor C:log C:orm labels Mar 23, 2023
@github-actions github-actions bot added C:collections C:Confix Issues and PR related to Confix C:Hubl Tool: Hubl C:x/circuit C:x/upgrade labels Mar 24, 2023
Comment on lines 60 to 83
return bz
}

func (cdc *LegacyAmino) marshalAnys(o interface{}) error {
func (cdc *LegacyAmino) marshalAnys(o any) error {
return types.UnpackInterfaces(o, types.AminoPacker{Cdc: cdc.Amino})
}

func (cdc *LegacyAmino) unmarshalAnys(o interface{}) error {
func (cdc *LegacyAmino) unmarshalAnys(o any) error {
return types.UnpackInterfaces(o, types.AminoUnpacker{Cdc: cdc.Amino})
}

func (cdc *LegacyAmino) jsonMarshalAnys(o interface{}) error {
func (cdc *LegacyAmino) jsonMarshalAnys(o any) error {
return types.UnpackInterfaces(o, types.AminoJSONPacker{Cdc: cdc.Amino})
}

func (cdc *LegacyAmino) jsonUnmarshalAnys(o interface{}) error {
func (cdc *LegacyAmino) jsonUnmarshalAnys(o any) error {
return types.UnpackInterfaces(o, types.AminoJSONUnpacker{Cdc: cdc.Amino})
}

func (cdc *LegacyAmino) Marshal(o interface{}) ([]byte, error) {
func (cdc *LegacyAmino) Marshal(o any) ([]byte, error) {
err := cdc.marshalAnys(o)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

(*github.com/cosmos/cosmos-sdk/codec.LegacyAmino).jsonMarshalAnys (codec/amino.go:71)
(*github.com/cosmos/cosmos-sdk/codec.LegacyAmino).MarshalJSON (codec/amino.go:142)
(github.com/cosmos/cosmos-sdk/types.ABCIMessageLogs).String (codec/amino.go:50)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).runMsgs (codec/amino.go:773)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).runTx (codec/amino.go:614)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).DeliverTx (codec/amino.go:410)

Comment on lines 139 to 146
}

// MarshalJSON implements codec.Codec interface
func (cdc *LegacyAmino) MarshalJSON(o interface{}) ([]byte, error) {
func (cdc *LegacyAmino) MarshalJSON(o any) ([]byte, error) {
err := cdc.jsonMarshalAnys(o)
if err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

(*github.com/cosmos/cosmos-sdk/codec.LegacyAmino).MarshalJSON (codec/amino.go:142)
(github.com/cosmos/cosmos-sdk/types.ABCIMessageLogs).String (codec/amino.go:50)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).runMsgs (codec/amino.go:773)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).runTx (codec/amino.go:614)
(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).DeliverTx (codec/amino.go:410)

OpWeightExec = "op_weight_msg_execute" //nolint:gosec
OpWeightMsgGrant = "op_weight_msg_grant"
OpWeightRevoke = "op_weight_msg_revoke"
OpWeightExec = "op_weight_msg_execute"

Check failure

Code scanning / gosec

Potential hardcoded credentials

Potential hardcoded credentials
OpWeightRevoke = "op_weight_msg_revoke" //nolint:gosec
OpWeightExec = "op_weight_msg_execute" //nolint:gosec
OpWeightMsgGrant = "op_weight_msg_grant"
OpWeightRevoke = "op_weight_msg_revoke"

Check failure

Code scanning / gosec

Potential hardcoded credentials

Potential hardcoded credentials
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"

Check failure

Code scanning / gosec

Potential hardcoded credentials

Potential hardcoded credentials
@@ -14,7 +14,7 @@
const (
DefaultWeightMsgUpdateParams int = 100

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

Check failure

Code scanning / gosec

Potential hardcoded credentials

Potential hardcoded credentials
@julienrbrt
Copy link
Member

Hey! Before you are doing the whole codebase, my two cents is that types, constant, structs, etc... should not always be grouped. It is best to keep them close to their methods, or usage; otherwise it is harder to read.

Baseapp here is the best example, I find after your changes it is way harder to read than before.
Usually, you group when things are related: https://github.com/uber-go/guide/blob/master/style.md#group-similar-declarations

Thoughts @kocubinski @alexanderbez @tac0turtle @mark-rushakoff ?

@julienrbrt
Copy link
Member

My laptop cannot handle the GitHub diff 😅 but your changes in the go.mod should be reverted.
Having a replace would prohibit the tooling to be installed with go install.

@tac0turtle
Copy link
Member

Please open smaller prs. Reviewing such large prs consumes too much time

@tac0turtle tac0turtle closed this Mar 24, 2023
@faddat
Copy link
Contributor Author

faddat commented Mar 24, 2023

hmmmmm -- kinda do want this.

I feel the codebase is a bit disorganized.

The go.mod stuff is just for using go.work while making the PR.

It is legit too large, but that's why I'm doing it between releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants