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

chore: refactor code quality issues #8932

Merged
merged 4 commits into from
Mar 22, 2021
Merged

chore: refactor code quality issues #8932

merged 4 commits into from
Mar 22, 2021

Conversation

akshgpt7
Copy link
Contributor

Description

Hey, I'm a Developer Outreach at DeepSource and ran DeepSource analysis on my fork of the repo. It found some interesting code quality improvements to consider.

This PR fixes a few of the issues detected for you to assess if it is right for you.
Happy to provide the tweaks separately otherwise :)

Summary of changes

  • Clean up copied struct fields with type conversion
  • Merge variable declaration with assignment
  • Fix unnecessary typecasting on bytes.Buffer
  • Replace bytes.Compare with bytes.Equal
  • Add .deepsource.toml file for continuous analysis on bug risks/performance/code-quality issues on new changes.

  • 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.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@alessio
Copy link
Contributor

alessio commented Mar 18, 2021

Hi. Thanks for taking the time to submit this patch and help making Cosmos SDK better! This looks good to me as long as tests pass 👍

@alexanderbez alexanderbez added the Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. label Mar 18, 2021
@alessio
Copy link
Contributor

alessio commented Mar 18, 2021

Test failures are unrelated and this PR can be merged as soon as we fix the race condition. My ACK still stands 👍

@fedekunze fedekunze added the A:automerge Automatically merge PR once all prerequisites pass. label Mar 19, 2021
@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #8932 (9154749) into master (5bd93bf) will decrease coverage by 0.04%.
The diff coverage is n/a.

❗ Current head 9154749 differs from pull request most recent head be8b188. Consider uploading reports for the commit be8b188 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8932      +/-   ##
==========================================
- Coverage   59.27%   59.23%   -0.05%     
==========================================
  Files         571      571              
  Lines       31827    31800      -27     
==========================================
- Hits        18867    18837      -30     
- Misses      10757    10761       +4     
+ Partials     2203     2202       -1     
Impacted Files Coverage Δ
x/auth/vesting/module.go 52.17% <0.00%> (-4.35%) ⬇️
x/upgrade/module.go 60.86% <0.00%> (-4.35%) ⬇️
x/mint/module.go 52.77% <0.00%> (-2.78%) ⬇️
x/auth/module.go 51.35% <0.00%> (-2.71%) ⬇️
x/crisis/module.go 56.75% <0.00%> (-2.71%) ⬇️
x/upgrade/keeper/keeper.go 74.22% <0.00%> (-2.50%) ⬇️
x/staking/module.go 59.52% <0.00%> (-2.39%) ⬇️
x/bank/module.go 55.81% <0.00%> (-2.33%) ⬇️
x/authz/module.go 48.83% <0.00%> (-2.33%) ⬇️
x/evidence/module.go 44.18% <0.00%> (-2.33%) ⬇️
... and 6 more

@mergify mergify bot merged commit 7b1d80e into cosmos:master Mar 22, 2021
@akshgpt7
Copy link
Contributor Author

@alessio Thanks for approving this! I'd just like to inform you that the issues fixed here were detected by running DeepSource analysis on the repo. If you like, you can activate analysis for your repository to detect such code quality issues/bug risks on the fly for every change made. You can also use the Autofix feature to fix them with one click.

Here's what you can do if you wish to activate DeepSource to continuously analyze your repository:

  • Sign up on DeepSource and activate analysis for this repository.
  • Create .deepsource.toml configuration which you can use to configure your analysis settings (this PR already added that, but feel free to edit it anytime).
  • Track/Check analysis here.

If you have any doubts or questions, you can check out the docs, or feel free to reach out :)

@akshgpt7
Copy link
Contributor Author

akshgpt7 commented Apr 5, 2021

@alessio @alexanderbez @aaronc
Do you need any help with activating DeepSource?
I ask so because the .deepsource.toml file that you merged will only take effect if analysis is activated.

@alessio
Copy link
Contributor

alessio commented Apr 6, 2021

@alessio @alexanderbez @aaronc
Do you need any help with activating DeepSource?

That'd be appreciated

@akshgpt7
Copy link
Contributor Author

akshgpt7 commented Apr 7, 2021

@alessio, you just need to follow these quick steps to activate it for this repo:

  • Sign up on DeepSource and click on "Activate new repo" on your dashboard.
  • Create .deepsource.toml configuration which you can use to configure your analysis settings (this PR already added that so you can choose the option that you already have a config file, but feel free to edit it anytime).
  • Track/Check analysis here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. 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.

6 participants