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

Goimports #4881

Merged
merged 16 commits into from
Aug 19, 2019
Merged

Goimports #4881

merged 16 commits into from
Aug 19, 2019

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Aug 9, 2019

  • added goimports
  • changed golangci.yml to only show what we dont have enabled

ref #4589

Signed-off-by: Marko Baricevic marbar3778@yahoo.com

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry: clog add [section] [-t <tag>] [-m <msg>]

  • Re-reviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

- added goimports
- changed golangci.yml to only show what we dont have enabled

Signed-off-by: Marko Baricevic <marbar3778@yahoo.com>
- maligned
- nakedret
- ineffassign
- errcheck
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be enabled

Copy link
Member Author

@tac0turtle tac0turtle Aug 9, 2019

Choose a reason for hiding this comment

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

lots of errors, some stuff is steaming from tests, i can disable this, or would we want the errrors on tests as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

same, blocked on the testing refactors

- govet
- unused
- deadcode
- golint
Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be enabled

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 currently has about 20+ errors, can spend time next week enabling it

Copy link
Collaborator

Choose a reason for hiding this comment

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

will enable this after @colin-axner 's testing refactors have been merged

@codecov
Copy link

codecov bot commented Aug 9, 2019

Codecov Report

Merging #4881 into master will increase coverage by <.01%.
The diff coverage is 49.49%.

@@            Coverage Diff             @@
##           master    #4881      +/-   ##
==========================================
+ Coverage   53.74%   53.74%   +<.01%     
==========================================
  Files         272      272              
  Lines       17105    17103       -2     
==========================================
- Hits         9193     9192       -1     
- Misses       7221     7224       +3     
+ Partials      691      687       -4

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK

@alexanderbez alexanderbez requested a review from fedekunze August 15, 2019 14:58
@alexanderbez alexanderbez added Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. next-point-release labels Aug 15, 2019
tac0turtle and others added 4 commits August 15, 2019 18:11
Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
@alexanderbez
Copy link
Contributor

@marbar3778 please signal when this is r4r again.

@tac0turtle
Copy link
Member Author

@alexanderbez its ready, just knocked another linter out quickly

@alexanderbez alexanderbez requested a review from fedekunze August 16, 2019 19:16
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK still stands. We should also enabled unparam

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

Good cleanup - I have several suggestions, but also there are some tests which should have not been deleted which should be reinstated (this last comment is blocking for me)

@@ -292,146 +292,6 @@ func TestValidatorBasics(t *testing.T) {
require.False(t, found)
}

// test how the validators are sorted, tests GetBondedValidatorsByPower
func GetValidatorSortingUnmixed(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this test deleted? These are vital tests of functionality which must be kept unless this is clearly duplicated somewhere (blocking 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.

i got this as unused code and couldn't find its uses used in the codebase, do we want to keep unused code around? I'm fine with putting it back

Copy link
Contributor

Choose a reason for hiding this comment

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

We definitely want both these tests which have been deleted in this file

Copy link
Member Author

@tac0turtle tac0turtle Aug 18, 2019

Choose a reason for hiding this comment

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

just for the heads up these tests fail and arent currently run, will put them back in and comment them out

Copy link
Contributor

@alexanderbez alexanderbez Aug 19, 2019

Choose a reason for hiding this comment

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

@marko, let's not comment them out, but rather add t.SkipNow() at the very top of the test function. Also, let's open up an issue and reference it to be fixed asap.

i.e.

func GetValidatorSortingUnmixed(t *testing.T) {
    // TODO: Evaluate and fix broken unit test.
    // ref: link
    t.SkipNow()

    // ...
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I second @alexanderbez

Copy link
Member Author

Choose a reason for hiding this comment

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

added it in

@@ -135,7 +135,7 @@ func AppStateFromGenesisFileFn(r *rand.Rand, config simulation.Config) (json.Raw
r.Read(privkeySeed)

privKey := secp256k1.GenPrivKeySecp256k1(privkeySeed)
newAccs = append(newAccs, simulation.Account{privKey, privKey.PubKey(), acc.Address})
newAccs = append(newAccs, simulation.Account{PrivKey: privKey, PubKey: privKey.PubKey(), Address: acc.Address})
Copy link
Contributor

Choose a reason for hiding this comment

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

Create and use a new function simulation.NewAccount(......

Copy link
Contributor

@alexanderbez alexanderbez Aug 16, 2019

Choose a reason for hiding this comment

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

This isn’t necessary (as in it shouldn’t be blocking) but can be added if the constructor is concise.

@@ -82,9 +82,8 @@ func PrefixEndBytes(prefix []byte) []byte {

// InclusiveEndBytes returns the []byte that would end a
// range query such that the input would be included
func InclusiveEndBytes(inclusiveBytes []byte) (exclusiveBytes []byte) {
exclusiveBytes = append(inclusiveBytes, byte(0x00))
return exclusiveBytes
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend reverting this change, even though it's more verbose, I find the variable names helpful in understanding this functionality

Copy link
Member Author

@tac0turtle tac0turtle Aug 16, 2019

Choose a reason for hiding this comment

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

would it be better to better the comment instead of reverting?

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 the variables would be clearer than a comment. But this is minor for me

@@ -156,7 +156,7 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState {
})
var lastValidatorPowers []types.LastValidatorPower
keeper.IterateLastValidatorPowers(ctx, func(addr sdk.ValAddress, power int64) (stop bool) {
lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{addr, power})
lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{Address: addr, Power: power})
Copy link
Contributor

Choose a reason for hiding this comment

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

Create and use a new function types.NewLastValidatorPower(.......

Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

@@ -292,146 +292,6 @@ func TestValidatorBasics(t *testing.T) {
require.False(t, found)
}

// test how the validators are sorted, tests GetBondedValidatorsByPower
func GetValidatorSortingUnmixed(t *testing.T) {
Copy link
Contributor

@alexanderbez alexanderbez Aug 19, 2019

Choose a reason for hiding this comment

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

@marko, let's not comment them out, but rather add t.SkipNow() at the very top of the test function. Also, let's open up an issue and reference it to be fixed asap.

i.e.

func GetValidatorSortingUnmixed(t *testing.T) {
    // TODO: Evaluate and fix broken unit test.
    // ref: link
    t.SkipNow()

    // ...
}

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK; we should open up an issue for those two failing tests though.

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

ACK - provided (@alexanderbez new comment is addressed) #4881 (comment)

👏 🌟 🌵

@tac0turtle tac0turtle mentioned this pull request Aug 19, 2019
@tac0turtle
Copy link
Member Author

#4925

@alexanderbez alexanderbez merged commit 3a4f1fc into master Aug 19, 2019
@alexanderbez alexanderbez deleted the marko/addgoimports branch August 19, 2019 16:06
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants