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

linter: enable early return #44564

Merged
merged 8 commits into from
Jun 12, 2023
Merged

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented Jun 10, 2023

What problem does this PR solve?

Issue Number: close #40786

Problem Summary:

What is changed and how it works?

In Go it is idiomatic to minimize nesting statements, a typical example is to avoid if-then-else constructions. This rule spots constructions like

if cond {
  // do something
} else {
  // do other thing
  return ...
}

where the if condition may be inverted in order to reduce nesting:

if !cond {
  // do other thing
  return ...
}

Check List

Tests

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

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@hawkingrei hawkingrei requested a review from a team as a code owner June 10, 2023 10:46
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 10, 2023
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei hawkingrei force-pushed the enable_early_return branch from 5dc62aa to fccad61 Compare June 11, 2023 15:45
@ti-chi-bot ti-chi-bot bot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. do-not-merge/needs-linked-issue labels Jun 11, 2023
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jun 12, 2023
@lance6716
Copy link
Contributor

/run-integration-br-test

@lance6716
Copy link
Contributor

/hold

please wait the rseult of BR/lightning CI

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 12, 2023
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 12, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 12, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-06-12 03:33:56.549168232 +0000 UTC m=+123386.003929520: ☑️ agreed by lance6716.
  • 2023-06-12 03:57:49.102982431 +0000 UTC m=+124818.557743734: ☑️ agreed by xhebox.

@lance6716
Copy link
Contributor

/run-integration-br-test

@lance6716
Copy link
Contributor

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 12, 2023
@hawkingrei hawkingrei requested a review from qw4990 June 12, 2023 05:19
@hawkingrei hawkingrei requested a review from XuHuaiyu June 12, 2023 05:34
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 12, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lance6716, xhebox, XuHuaiyu

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

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [XuHuaiyu,lance6716,xhebox]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot merged commit c7f2a23 into pingcap:master Jun 12, 2023
@hawkingrei hawkingrei deleted the enable_early_return branch June 14, 2023 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enable every linter for the every package
4 participants