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

*: fix the static checks from the latest tools #7014

Merged
merged 1 commit into from
Aug 30, 2023

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Aug 30, 2023

What problem does this PR solve?

Issue Number: ref #4399.

pkg/utils/apiutil/apiutil.go:53:2: G101: Potential hardcoded credentials (gosec)
	PDAllowFollowerHandleHeader = "PD-Allow-follower-handle"
	^
pkg/core/region.go:1667:14: SA1019: reflect.SliceHeader has been deprecated since Go 1.21 and an alternative has been available since Go 1.17: Use unsafe.Slice or unsafe.SliceData instead. (staticcheck)
	pbytes := (*reflect.SliceHeader)(unsafe.Pointer(&b))
	            ^
pkg/core/region.go:1668:15: SA1019: reflect.StringHeader has been deprecated since Go 1.21 and an alternative has been available since Go 1.20: Use unsafe.String or unsafe.StringData instead. (staticcheck)
	pstring := (*reflect.StringHeader)(unsafe.Pointer(&s))
	             ^
pkg/encryption/key_manager_test.go:41:2: G101: Potential hardcoded credentials (gosec)
	testMasterKey     = "8fd7e3e917c170d92f3e51a981dd7bc8fba11f3df7d8df994842f6e86f69b530"
	^
pkg/encryption/key_manager_test.go:42:2: G101: Potential hardcoded credentials (gosec)
	testMasterKey2    = "8fd7e3e917c170d92f3e51a981dd7bc8fba11f3df7d8df994842f6e86f69b531"
	^
pkg/encryption/key_manager_test.go:43:2: G101: Potential hardcoded credentials (gosec)
	testCiphertextKey = "8fd7e3e917c170d92f3e51a981dd7bc8fba11f3df7d8df994842f6e86f69b532"
	^
pkg/schedule/schedulers/hot_region.go:178:23: G601: Implicit memory aliasing in for loop. (gosec)
				from.AddInfluence(&p.origin, -weight)
				                  ^
pkg/schedule/schedulers/hot_region.go:181:21: G601: Implicit memory aliasing in for loop. (gosec)
				to.AddInfluence(&p.origin, weight)
				                ^
pkg/schedule/schedulers/hot_region.go:529:39: G601: Implicit memory aliasing in for loop. (gosec)
		maxCur = statistics.MaxLoad(maxCur, &detail.LoadPred.Current)
		                                    ^
server/grpc_service.go:213:25: G602: Potentially accessing slice out of bounds (gosec)
	keyspaceGroupsTotal := resps[0].KeyspaceGroupsTotal

What is changed and how does it work?

Fix some static check errors from the latest version of tools.

Check List

Tests

  • Unit test
  • Integration test

Release note

None.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 30, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • nolouch

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 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. labels Aug 30, 2023
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 30, 2023
@@ -50,7 +50,7 @@ const (
// PDRedirectorHeader is used to mark which PD redirected this request.
PDRedirectorHeader = "PD-Redirector"
// PDAllowFollowerHandleHeader is used to mark whether this request is allowed to be handled by the follower PD.
PDAllowFollowerHandleHeader = "PD-Allow-follower-handle"
PDAllowFollowerHandleHeader = "PD-Allow-follower-handle" // #nosec G101
Copy link
Member

Choose a reason for hiding this comment

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

I am confused why we have to add this comment :(

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 seems like a false positive error:

pkg/utils/apiutil/apiutil.go:53:2: G101: Potential hardcoded credentials (gosec)
	PDAllowFollowerHandleHeader = "PD-Allow-follower-handle"
	^

@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #7014 (15fad8e) into master (9a574ed) will decrease coverage by 0.28%.
Report is 3 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #7014      +/-   ##
==========================================
- Coverage   74.33%   74.05%   -0.28%     
==========================================
  Files         433      433              
  Lines       46097    46099       +2     
==========================================
- Hits        34265    34138     -127     
- Misses       8830     8945     +115     
- Partials     3002     3016      +14     
Flag Coverage Δ
unittests 74.05% <100.00%> (-0.28%) ⬇️

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

@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 Aug 30, 2023
@nolouch
Copy link
Contributor

nolouch commented Aug 30, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 30, 2023

@nolouch: 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.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 30, 2023

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

Commit hash: 15fad8e

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 30, 2023
@ti-chi-bot ti-chi-bot bot merged commit 39cff3b into tikv:master Aug 30, 2023
24 checks passed
@JmPotato JmPotato deleted the fix_static_check branch August 30, 2023 11:55
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.

4 participants