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

A bit of cleanup based on goconst tool #8529

Merged
merged 9 commits into from
Mar 2, 2021

Conversation

drpaneas
Copy link
Contributor

@drpaneas drpaneas commented Feb 28, 2021

What type of PR is this?

Other (mosty cosmetic)

What does this PR do? Why is it needed?

Make the project one step closer to be compliant with goconst which is part of golangci

Which issues(s) does this PR fix?

None

Other notes for review

If you prefer 1 PR == 1 commit, let me know so I can squash the commits.

Copy link
Contributor

@rkapka rkapka left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. Looks nice, I just had a few minor comments.

@@ -14,6 +14,8 @@ import (
"google.golang.org/grpc/status"
)

const epochError = "Cannot retrieve information about an epoch in the future, current epoch %d, requesting %d"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please change all ...Error to err...? E.g. errEpoch. This is the convention we use. Also, this name should be more expressive: errNoEpochInfo, just like in beacon-chain/rpc/beacon/validators_test.go.

@@ -22,7 +22,7 @@ import (
"github.com/prysmaticlabs/prysm/validator/keymanager/derived"
)

var (
const (
Copy link
Contributor

Choose a reason for hiding this comment

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

The exact same mnemonic repeats in 3 places. I think it warrants moving to a shared package.

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 thought so as well but didn't come up with any good place. Is there any preference where should I move this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can create a new constants.go file inside validator/testing.

@@ -32,6 +32,10 @@ import (
"github.com/prysmaticlabs/prysm/shared/timeutils"
)

const (
noEpochInfoError = "Cannot retrieve information about an epoch in the future"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
noEpochInfoError = "Cannot retrieve information about an epoch in the future"
noFutureEpochInfoError = "Cannot retrieve information about an epoch in the future"

Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to step away from suggestion comments for names. Committing this suggestion will break the build because a proper refactor won't happen.

Just my observation :-)

@drpaneas
Copy link
Contributor Author

drpaneas commented Mar 1, 2021

I am afraid adding a new files requires some Bazel related configuration, because the CI is failing. Any tips would be appreciated :)

validator/testing/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 | 0s
-- | --
  | @@ -4,6 +4,7 @@
  | name = "go_default_library",
  | testonly = True,
  | srcs = [
  | +        "constants.go",
  | "mock_protector.go",
  | "mock_slasher.go",
  | "protection_history.go",
  | FAIL: Gazelle needs to be run
  | Please run bazel run //:gazelle -- fix

@rauljordan
Copy link
Contributor

rauljordan commented Mar 1, 2021 via email

@rauljordan
Copy link
Contributor

cc @drpaneas

@drpaneas
Copy link
Contributor Author

drpaneas commented Mar 1, 2021

Hi Panagiotis, you can run bazel run //:gazelle -- fix to resolve your issue

Alright, many thanks for the blazing fast reply :D I did run this. Let's see if CI likes it this time :)

@codecov
Copy link

codecov bot commented Mar 1, 2021

Codecov Report

Merging #8529 (3d0e0c6) into develop (b3dcbfe) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #8529      +/-   ##
===========================================
+ Coverage    58.19%   58.21%   +0.01%     
===========================================
  Files          461      461              
  Lines        33100    33100              
===========================================
+ Hits         19264    19268       +4     
+ Misses       10910    10907       -3     
+ Partials      2926     2925       -1     

@prylabs-bulldozer prylabs-bulldozer bot merged commit 46f6bd6 into prysmaticlabs:develop Mar 2, 2021
@drpaneas drpaneas deleted the cleanup branch March 2, 2021 12:02
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

5 participants