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

Miscellaneous code quality improvements #7414

Merged
merged 13 commits into from
Oct 4, 2020

Conversation

rkapka
Copy link
Contributor

@rkapka rkapka commented Oct 2, 2020

What type of PR is this?

Other - code quality improvements

What does this PR do? Why is it needed?

This PR fixes miscellaneous code quality issues found by the DeepSource tool here: https://deepsource.io/gh/rkapka/prysm/. And some things that GoLand complained about.

Which issues(s) does this PR fix?

Fixes #6747

Other notes for review

N/A

@rkapka rkapka requested a review from a team as a code owner October 2, 2020 12:11
@codecov
Copy link

codecov bot commented Oct 2, 2020

Codecov Report

Merging #7414 into master will decrease coverage by 0.17%.
The diff coverage is 42.85%.

@@            Coverage Diff             @@
##           master    #7414      +/-   ##
==========================================
- Coverage   60.16%   59.98%   -0.18%     
==========================================
  Files         424      419       -5     
  Lines       30669    30252     -417     
==========================================
- Hits        18451    18148     -303     
+ Misses       9185     9113      -72     
+ Partials     3033     2991      -42     

@@ -143,6 +144,8 @@ func (s *Service) ReceiveBlockBatch(ctx context.Context, blocks []*ethpb.SignedB
}

if err := s.VerifyWeakSubjectivityRoot(s.ctx); err != nil {
// log.Fatalf will prevent defer from being called
cleanup()
Copy link
Member

Choose a reason for hiding this comment

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

why not just call span.End() here instead of introducing a third variable?

We do this in other places as well (e.g. call span.End())

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to follow the same pattern everywhere, but I agree that span.End can just be called directly.

Copy link
Member

Choose a reason for hiding this comment

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

Issue is this pattern is not used anywhere in the code base so this actually creates inconsistency.
Screen Shot 2020-10-04 at 7 40 01 AM

Here's a few options:

1.) Revert this PR to use span.End and we stick with span.End
2.) Revert this PR to use span.End and in the subsequent PR we replace all with cleanup()
3.) In this PR, we replace all span.End usages with cleanup()

I don't have a strong preference the option, you can choose one, but i do want some consistencies

Copy link
Member

Choose a reason for hiding this comment

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

discussed offline and this was resolved

@@ -143,6 +144,8 @@ func (s *Service) ReceiveBlockBatch(ctx context.Context, blocks []*ethpb.SignedB
}

if err := s.VerifyWeakSubjectivityRoot(s.ctx); err != nil {
// log.Fatalf will prevent defer from being called
Copy link
Member

Choose a reason for hiding this comment

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

I think the real problem is that we shouldn't be using log.Fatalf. This isn't a graceful shutdown and can cause other issues like corrupt data writes: #7382

Copy link
Contributor Author

@rkapka rkapka Oct 4, 2020

Choose a reason for hiding this comment

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

I absolutely agree. We can discuss this during the OKRs meeting since I am about to take a look at logging in general.

@prylabs-bulldozer prylabs-bulldozer bot merged commit 3e0b205 into master Oct 4, 2020
@delete-merged-branch delete-merged-branch bot deleted the deep-source-improvements branch October 4, 2020 15:03
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.

DeepSource: Potential code quality issues found
3 participants