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

*: sort-statement-order #28968

Merged
merged 2 commits into from
Oct 20, 2021
Merged

Conversation

milasuperstar
Copy link
Contributor

@milasuperstar milasuperstar commented Oct 20, 2021

Signed-off-by: Mila Wu wumila1996@gmail.com

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
In the uber golang style, there are two rules:

  • Functions should be sorted in rough call order.

  • Functions in a file should be grouped by receiver.

I think we should follow this rule.

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Release note

None

Signed-off-by: Mila Wu <wumila1996@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Oct 20, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • disksing

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 20, 2021
@CLAassistant
Copy link

CLAassistant commented Oct 20, 2021

CLA assistant check
All committers have signed the CLA.

@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 20, 2021
@ti-chi-bot
Copy link
Member

@hawkingrei: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@hawkingrei
Copy link
Member

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Oct 20, 2021
@milasuperstar
Copy link
Contributor Author

In the uber golang style, there are two rules:

  • Functions should be sorted in rough call order.

  • Functions in a file should be grouped by receiver.

I think we should follow this rule.

@JmPotato
Copy link
Member

JmPotato commented Oct 20, 2021

BTW, could you please finish the PR description to explain these changes a little bit? That would be nice for other reviewers to review. :)

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 20, 2021
@disksing
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 9376f1d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 20, 2021
@milasuperstar
Copy link
Contributor Author

BTW, could you please finish the PR description to explain these changes a little bit? That would be nice for other reviewers to review. :)

Done. ;)

Copy link
Member

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot merged commit 85437b3 into pingcap:master Oct 20, 2021
@breezewish
Copy link
Member

I'm wondering do we have an official place that mentions that we should follow uber's go style? Otherwise there are multiple styles in the wild and it is not suitable to apply rules from different styles together.

@milasuperstar milasuperstar deleted the sort-statement-order branch October 20, 2021 06:20
@tisonkun
Copy link
Contributor

I second @breeswish and suspect that if we don't have a style checker, this change is meaningless and unmaintainable.

It's totally OK to follow some codestyle we don't forbid when writing new code or refactor, but please prevent from do refactor for formatting without guard only - it causes noise.

@tisonkun
Copy link
Contributor

tisonkun commented Oct 20, 2021

an official place that mentions that we should follow uber's go style

No. We've made a style guide on dev guide (later we simplify it) and the original context includes:

Make sure the PR follows our code style and quality guide. For Go and Rust, there are built-in tools with the compiler toolchain.

If you want to improve styles not covered in the style guide, you can comment that you think it would improve the code readability but it is not mandatory. Do not block PRs from being merged based only on personal style preferences.

The PR author should not combine nontrivial style changes and functional changes in one PR, because it violates the guideline covered earlier: one PR does one thing.

The simplify (and current) version is:

Style. Code in the pull request should follow common programming style. For Go and Rust, there are built-in tools with the compiler toolchain. However, sometimes the existing code is inconsistent with the style guide, you should maintain consistency with the existing code or file a new issue to fix the existing code style first.

I think it means that, if the style is not documented and/or guarded by CI, it's unnecessary and suspicious to force to follow.

@disksing
Copy link
Contributor

IMO any uncontroversial and positive improvement to the code should be allowed to merge, regardless of whether it's a PR on its own or with other refactorings, or whether there are rules that specify the style of code we need to follow.

@tisonkun
Copy link
Contributor

tisonkun commented Oct 20, 2021

uncontroversial

Here is obviously controversies now.

positive improvement
whether there are rules that specify the style of code we need to follow

It's suspicious. "Functions should be sorted in rough call order.", what is "rough"?

To be clear, I totally agree with follow style you like and not forbidden when writing new code or non style-only refactor. If you like a style and want to apply in the codebase,

If you want to improve styles not covered in the style guide, you can comment that you think it would improve the code readability but it is not mandatory.

I'm afraid that we open the gate to random changes which is hardly proven to be good or converged. These changes increase the difficulty to do cherry-pick without non-trivial benefits.

  • Functions should be sorted in rough call order.
  • Functions in a file should be grouped by receiver.

They're good to follow when writing new code, and if you want to spread in the community, start a thread to add it to our style guide - but still, it will apply on new code in recommend without a checker. Also reject such style-only changes without checker or official rules to follow save our bandwidth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants