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

Enable static check sa4006 #13350

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Enable static check sa4006 #13350

merged 1 commit into from
Dec 15, 2023

Conversation

prestonvanloon
Copy link
Member

@prestonvanloon prestonvanloon commented Dec 15, 2023

What type of PR is this?

Other

What does this PR do? Why is it needed?

Enables SA4006 and fixes violations.

This build will fail until this PR is rebased after #13344, therefore this is a draft until that PR
merges.

Which issues(s) does this PR fix?

Other notes for review

https://staticcheck.dev/docs/checks/#SA4006

@prestonvanloon prestonvanloon force-pushed the sa4006 branch 2 times, most recently from 31cb10b to 67fa629 Compare December 15, 2023 03:27
@prestonvanloon prestonvanloon marked this pull request as ready for review December 15, 2023 03:27
@prestonvanloon prestonvanloon requested a review from a team as a code owner December 15, 2023 03:27
kasey
kasey previously approved these changes Dec 15, 2023
@prestonvanloon prestonvanloon added this pull request to the merge queue Dec 15, 2023
@prestonvanloon prestonvanloon removed this pull request from the merge queue due to a manual request Dec 15, 2023
@@ -53,13 +53,17 @@ func (c beaconApiValidatorClient) getBeaconBlock(ctx context.Context, slot primi
ver = produceBlindedBlockResponseJson.Version
blinded = true
decoder = json.NewDecoder(bytes.NewReader(produceBlindedBlockResponseJson.Data))
} else if errJson == nil {
return nil, errors.New("failed to query GET REST endpoint: nil result")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, errors.New("failed to query GET REST endpoint: nil result")
return nil, errors.Wrap(err, "failed to query GET REST endpoint")

Comment on lines +31 to +33
if ctx.Err() != nil {
return ctx.Err()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you insert the error check here, but replaced ctx with _ elsewhere?

Copy link
Member Author

@prestonvanloon prestonvanloon Dec 15, 2023

Choose a reason for hiding this comment

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

Good question... I started subjectively adding some context liveness checks but only did it in a few places. I can revert if it doesnt make sense

Comment on lines +95 to +97
if ctx.Err() != nil {
return ctx.Err()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

And here you ignore the context coming from StartSpan and do an error check on the original context.

Copy link
Contributor

Choose a reason for hiding this comment

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

In practice this is fine because the cancellation won't come from tracing, it will come from the parent context, but in principle we should always use the deepest context possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh lol i expanded the code pane after seeing your slack message - I too missed the interleaved func def 🤦

Comment on lines +22 to +24
if ctx.Err() != nil {
return nil, ctx.Err()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

more error checks

Comment on lines +19 to +21
if ctx.Err() != nil {
return ctx.Err()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

more error checks

Comment on lines +37 to +39
if ctx.Err() != nil {
return nil, ctx.Err()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

more error checks

@prestonvanloon prestonvanloon added this pull request to the merge queue Dec 15, 2023
Merged via the queue into develop with commit db09648 Dec 15, 2023
16 of 17 checks passed
@prestonvanloon prestonvanloon deleted the sa4006 branch December 15, 2023 17:10
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.

3 participants