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: add gci linter #16605

Merged
merged 2 commits into from
Jun 22, 2023
Merged

style: add gci linter #16605

merged 2 commits into from
Jun 22, 2023

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Jun 18, 2023

closes: #16606

Description

This PR sorts the imports to the SDK deterministically.

linters-settings:
  gci:
    sections:
      - standard # Standard section: captures all standard packages.
      - default # Default section: contains all imports that could not be matched to another section type.
      - prefix(cosmossdk.io) # new modules
      - prefix(github.com/cosmos/cosmos-sdk) #old import

review:
The PR itself is 100% reproducible, just run make lint-fix :)


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)

@julienrbrt
Copy link
Member

Wow that's an awesome linter!!

@julienrbrt
Copy link
Member

Can you make CI happy? One file isn't gofumped it says.

@faddat
Copy link
Contributor Author

faddat commented Jun 18, 2023

happy to :)

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

Amazing find!! This needs further refinement the way we do it in the sdk and is recommended is to group third party imports and group self imports. This adds multiple sections and chnages what developers should do

@faddat
Copy link
Contributor Author

faddat commented Jun 19, 2023

I think that this eliminates the developer work, other than running make lint-fix before pushing, eliminating the need for developers to know what to do, other than to run make lint-fix before making a PR.

If you've got ideas as to how to restructure the grouping though, I'm all ears :).

I view this as part of:

And the results are tangible here:

So you'd like to see cosmossdk.io grouped with github.com/cosmos/cosmos-sdk?

@julienrbrt
Copy link
Member

julienrbrt commented Jun 19, 2023

So you'd like to see cosmossdk.io grouped with github.com/cosmos/cosmos-sdk?

I think it is just: std, default, cosmossdk.io, cosmos/cosmos-sdk.
Maybe blank imports shouldn't be grouped separately either, not sure.

@faddat
Copy link
Contributor Author

faddat commented Jun 19, 2023

Any better? cool part here is that was one command :).

Quite happy to work it into whatever form that's needed.

@julienrbrt
Copy link
Member

Can you make CI happy? One file isn't gofumped it says.

I think you need to re-run that and we can merge.

@faddat
Copy link
Contributor Author

faddat commented Jun 21, 2023

ah, sure thing :). I'll fix conflicts and re-run now.

@julienrbrt
Copy link
Member

Thanks! Orm tests aren't failing because of your PR, so checking....

@faddat
Copy link
Contributor Author

faddat commented Jun 22, 2023

that is wierd... I'll merge in main and try again. It should change nothing? (I think?)

@julienrbrt
Copy link
Member

that is wierd... I'll merge in main and try again. It should change nothing? (I think?)

Feel free to merge main, that test is flaky: #16655.
We'll add automerge once it is merged.

auto-merge was automatically disabled June 22, 2023 13:42

Head branch was pushed to by a user without write access

@julienrbrt julienrbrt added this pull request to the merge queue Jun 22, 2023
Merged via the queue into cosmos:main with commit 6afece6 Jun 22, 2023
43 of 46 checks passed
@julienrbrt
Copy link
Member

I will backport this to v0.50.x, otherwise when we backport features to v0.50 we keep getting import conflicts (while v0.50 is at this point equivalent to main).

@julienrbrt julienrbrt mentioned this pull request Jun 29, 2023
19 tasks
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.

Sort imports deterministically
3 participants