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

RPC:golint fix #714

Merged
merged 5 commits into from
Jul 28, 2020
Merged

RPC:golint fix #714

merged 5 commits into from
Jul 28, 2020

Conversation

ShadowErii
Copy link
Contributor

However,i don't get why if i return error last in a method,it will increse the nums the reciever.Types().Method()(including that method),which will cause getting more callbacks

@ucwong
Copy link
Member

ucwong commented Jul 28, 2020

Which line ?

@ucwong ucwong requested a review from DhunterAO July 28, 2020 07:14
@@ -93,8 +93,8 @@ func (s *testService) Rets() (string, error) {
}

//lint:ignore ST1008 returns error first on purpose.
func (s *testService) InvalidRets1() (string, error) {
return "", nil
func (s *testService) InvalidRets1() (error, string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignore the ST1008 check here , and then it won't include in the callbacks

Copy link
Member

Choose a reason for hiding this comment

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

InvalidRets1 is made as wrong format method for testing

Copy link
Member

Choose a reason for hiding this comment

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

So we expect it is wrong

@codecov
Copy link

codecov bot commented Jul 28, 2020

Codecov Report

Merging #714 into master will decrease coverage by 0.14%.
The diff coverage is 63.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #714      +/-   ##
==========================================
- Coverage   50.14%   49.99%   -0.15%     
==========================================
  Files         421      421              
  Lines       53533    53385     -148     
==========================================
- Hits        26844    26691     -153     
- Misses      24609    24620      +11     
+ Partials     2080     2074       -6     
Impacted Files Coverage Δ
cmd/cortex/cvm.go 2.77% <0.00%> (ø)
cmd/cortex/cvm_handler.go 0.00% <0.00%> (ø)
node/endpoints.go 57.77% <0.00%> (ø)
rpc/http.go 60.00% <80.00%> (ø)
rpc/client.go 81.27% <100.00%> (+0.28%) ⬆️
rpc/server.go 75.55% <100.00%> (ø)
rpc/types.go 95.29% <100.00%> (-0.06%) ⬇️
p2p/discover/table.go 82.50% <0.00%> (-2.50%) ⬇️
p2p/discover/lookup.go 95.23% <0.00%> (-1.91%) ⬇️
ctxc/downloader/statesync.go 65.75% <0.00%> (-1.17%) ⬇️
... and 13 more

@@ -30,6 +30,8 @@ import (
"time"
)

type contextKey string

Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to use a cname here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes,it's better not to use string as key in the context.withvalue() ,i thought

Copy link
Member

Choose a reason for hiding this comment

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

OK, it seems from golint rules

Copy link
Member

Choose a reason for hiding this comment

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

It will be better to use name of httpContextKey or rpcContextKey with more meanings than contextKey here .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok,
it avoid key collisions by defining a separate type,although may never happen :)

@ucwong ucwong self-requested a review July 28, 2020 08:39
Copy link
Member

@ucwong ucwong left a comment

Choose a reason for hiding this comment

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

LGTM

@ucwong ucwong merged commit 6ed9571 into master Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants