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

lint: enable stylecheck #1960

Merged
merged 4 commits into from
Jul 5, 2022
Merged

lint: enable stylecheck #1960

merged 4 commits into from
Jul 5, 2022

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Jul 4, 2022

Closes: #XXX

What is the purpose of the change

Follow-up to: #1897

Linter that enforces style rules. A subset of rules from the staticcheck binary.

Brief Changelog

  • disable annoying check requiring "Id" to be "ID"
  • ensure that receivers are named consistently
  • remove duplicate imports that had different identifiers
  • remove redundant types in var declarations
  • errors messages are not capitalized
  • godoc starts with var name

Testing and Verifying

This change is a trivial rework / code cleanup without any test coverage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@p0mvn p0mvn changed the title lint: stylecheck lint: enable stylecheck Jul 4, 2022
@github-actions github-actions bot added C:app-wiring Changes to the app folder C:CLI C:x/gamm Changes, features and bugs related to the gamm module. C:x/incentives C:x/pool-incentives C:x/tokenfactory C:x/txfees T:CI labels Jul 4, 2022
@p0mvn
Copy link
Member Author

p0mvn commented Jul 4, 2022

Anecdotally, it feels that this linter caused the largest increase in time it takes to run golangci-lint run

However, it does seem that it was helpful in enforcing consistency so might still be worth trying it.

I think it should be another candidate to be potentially removed if linter times become a problem. Instead, we can run it every now and then to clean up the codebase

@p0mvn p0mvn marked this pull request as ready for review July 4, 2022 18:29
@p0mvn p0mvn requested a review from a team July 4, 2022 18:29
@p0mvn
Copy link
Member Author

p0mvn commented Jul 4, 2022

Anecdotally, it feels that this linter caused the largest increase in time it takes to run golangci-lint run

However, it does seem that it was helpful in enforcing consistency so might still be worth trying it.

I think it should be another candidate to be potentially removed if linter times become a problem. Instead, we can run it every now and then to clean up the codebase

On another look, seems I was wrong - the difference was likely due to cache. After timing these again:

git checkout main
time golangci-lint run

real    0m1.441s
user    0m5.352s
sys     0m1.170s
git checkout roman/lint-stylecheck
time golangci-lint run

real    0m1.465s
user    0m5.423s
sys     0m1.231s

Going to leave this here still in case anyone has thoughts

@@ -196,59 +196,59 @@ func (pa Pool) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDen
return sdk.NewCoin(tokenInDenom, tokenInAmt), nil
}

func (pa *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, swapFee sdk.Dec) (tokenIn sdk.Coin, err error) {
tokenIn, err = pa.CalcInAmtGivenOut(ctx, tokenOut, tokenInDenom, swapFee)
func (p *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, swapFee sdk.Dec) (tokenIn sdk.Coin, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

yay pa -> p !

@mattverse
Copy link
Member

mattverse commented Jul 5, 2022

doesn't seem like a big increase in time / a big overhead just from the stats roman provided

@p0mvn p0mvn merged commit e398235 into main Jul 5, 2022
@p0mvn p0mvn deleted the roman/lint-stylecheck branch July 5, 2022 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants