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

*: improve the linter and fix some bugs #8015

Merged
merged 9 commits into from
Apr 11, 2024
Merged

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Apr 2, 2024

What problem does this PR solve?

Issue Number: Close #8019.

What is changed and how does it work?

Check List

Tests

  • Unit test

Release note

None.

Copy link
Contributor

ti-chi-bot bot commented Apr 2, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HuSharp
  • JmPotato

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 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. labels Apr 2, 2024
@ti-chi-bot ti-chi-bot bot requested review from nolouch and Yisaer April 2, 2024 10:28
@@ -386,8 +386,7 @@ func (c *ResourceGroupsController) Start(ctx context.Context) {
}

case gc := <-c.tokenBucketUpdateChan:
now := gc.run.now
go gc.handleTokenBucketUpdateEvent(c.loopCtx, now)
go gc.handleTokenBucketUpdateEvent(c.loopCtx)
Copy link
Member Author

Choose a reason for hiding this comment

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

now is not used, we need to confirm if it is expected.

Copy link
Member

Choose a reason for hiding this comment

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

It's okay to remove it

@@ -797,6 +797,7 @@ func (c *tsoClient) processRequests(
stream tsoStream, dcLocation string, tbc *tsoBatchController,
) error {
requests := tbc.getCollectedRequests()
// nolint
Copy link
Member Author

Choose a reason for hiding this comment

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

defer is in the loop, not sure if it is right.

@@ -108,7 +108,8 @@ type ControllerConfig struct {
}

// Adjust adjusts the configuration and initializes it with the default value if necessary.
func (rmc *ControllerConfig) Adjust(meta *configutil.ConfigMetaData) {
// FIXME: is it expected?
func (rmc *ControllerConfig) Adjust(_ *configutil.ConfigMetaData) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Adjust doesn't use meta, is it expected?

Copy link
Member

Choose a reason for hiding this comment

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

IMO, it's better use meta for the method Adjust of RequestUnitConfig.

@@ -347,7 +347,7 @@ func (c *RuleChecker) fixLooseMatchPeer(region *core.RegionInfo, fit *placement.
if region.GetLeader().GetId() != peer.GetId() && rf.Rule.Role == placement.Leader {
ruleCheckerFixLeaderRoleCounter.Inc()
if c.allowLeader(fit, peer) {
return operator.CreateTransferLeaderOperator("fix-leader-role", c.cluster, region, region.GetLeader().GetStoreId(), peer.GetStoreId(), []uint64{}, 0)
return operator.CreateTransferLeaderOperator("fix-leader-role", c.cluster, region, peer.GetStoreId(), []uint64{}, 0)
Copy link
Member Author

Choose a reason for hiding this comment

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

transfer leader doesn't need a source store id

Copy link
Member

Choose a reason for hiding this comment

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

It isn't necessary for source.

@@ -32,7 +32,7 @@ type Request interface {
getCount() uint32
// process sends request and receive response via stream.
// count defines the count of timestamps to retrieve.
process(forwardStream stream, count uint32, tsoProtoFactory ProtoFactory) (tsoResp, error)
process(forwardStream stream, count uint32) (tsoResp, error)
Copy link
Member Author

Choose a reason for hiding this comment

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

we don't use factory in process

@@ -556,7 +556,7 @@ func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error {

if errCh == nil {
doneCh = make(chan struct{})
defer close(doneCh)
defer close(doneCh) // nolint
Copy link
Member Author

Choose a reason for hiding this comment

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

defer here is not right.

@@ -100,7 +100,8 @@ func ReadGetJSONWithBody(re *require.Assertions, client *http.Client, url string
if err != nil {
return err
}
return checkResp(resp, StatusOK(re), ExtractJSON(re, data))
checkOpts = append(checkOpts, StatusOK(re), ExtractJSON(re, data))
Copy link
Member Author

Choose a reason for hiding this comment

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

previously this function was not right

@@ -118,7 +119,7 @@ func (r *RegionSplitter) splitRegionsByKeys(parCtx context.Context, splitKeys []
r.handler.ScanRegionsByKeyRange(groupKeys, results)
}
case <-ctx.Done():
break
break outerLoop
Copy link
Member Author

Choose a reason for hiding this comment

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

it won't exit the for loop

Copy link

codecov bot commented Apr 3, 2024

Codecov Report

Merging #8015 (14503e3) into master (67461dd) will increase coverage by 0.04%.
The diff coverage is 76.01%.

❗ Current head 14503e3 differs from pull request most recent head 013fbc4. Consider uploading reports for the commit 013fbc4 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8015      +/-   ##
==========================================
+ Coverage   77.27%   77.32%   +0.04%     
==========================================
  Files         468      468              
  Lines       60890    60868      -22     
==========================================
+ Hits        47055    47068      +13     
+ Misses      10291    10261      -30     
+ Partials     3544     3539       -5     
Flag Coverage Δ
unittests 77.32% <76.01%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@ -76,7 +76,7 @@ func (suite *regionSplitterTestSuite) SetupSuite() {
suite.ctx, suite.cancel = context.WithCancel(context.Background())
}

func (suite *regionSplitterTestSuite) TearDownTest() {
func (suite *regionSplitterTestSuite) TearDownSuite() {
Copy link
Member Author

Choose a reason for hiding this comment

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

We need use TearDownSuite instead of TearDownTest

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 3, 2024
@@ -181,9 +181,6 @@ static: install-tools pre-build
@ gofmt -s -l -d $(PACKAGE_DIRECTORIES) 2>&1 | awk '{ print } END { if (NR > 0) { exit 1 } }'
@ echo "golangci-lint ..."
@ golangci-lint run --verbose $(PACKAGE_DIRECTORIES) --allow-parallel-runners
@ echo "revive ..."
@ revive -formatter friendly -config revive.toml $(PACKAGES)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to remove revive.toml also?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2024
@@ -797,6 +797,7 @@ func (c *tsoClient) processRequests(
stream tsoStream, dcLocation string, tbc *tsoBatchController,
) error {
requests := tbc.getCollectedRequests()
// nolint
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can create a method to handle batch trace operations

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 7, 2024

PR needs rebase.

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 kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 10, 2024
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
@rleungx rleungx removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 11, 2024
@rleungx rleungx requested review from HuSharp and removed request for Yisaer April 11, 2024 03:38
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 11, 2024
@HuSharp
Copy link
Member

HuSharp commented Apr 11, 2024

/merge

Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

@HuSharp: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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.

Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

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

Commit hash: 14503e3

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 11, 2024
Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

@rleungx: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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.

@ti-chi-bot ti-chi-bot bot merged commit 7e18a69 into tikv:master Apr 11, 2024
22 checks passed
@rleungx rleungx deleted the improve-linter branch April 11, 2024 09:09
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/XXL Denotes a PR that changes 1000+ 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.

Use one linter
4 participants