-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
tools: Add code complexity linter, gocyclo #1593
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1593 +/- ##
==========================================
- Coverage 64.31% 64.12% -0.2%
==========================================
Files 122 122
Lines 6704 6754 +50
==========================================
+ Hits 4312 4331 +19
- Misses 2147 2177 +30
- Partials 245 246 +1 |
Fixing |
Gocyclo is a code complexity linter. It uses cyclomatic complexity. Cyclomatic complexity essentially measures the number of different paths code could go through. (The conditional in a for loop counts as adding one path) It looks at this on a per-function level. The idea that this would be enforcing is that if there are too many different paths code can go through in a function, it needs to be better split up. (A function with too many code paths is hard to reason about) The complexity which we want the linter to start failing on is configurable. The default is 10. Change the "Cyclo" parameter in `tools/gometalinter.json` to try other values.
* Adds a Min function to Int, and uses that in the slash function * Adds a getHeight helper function to iavlstore * Adds a splitPath function to baseapp * Changes cyclo param from 10 to 11
a9f8db6
to
17b5370
Compare
I added nolint in many places. For a couple of them the relevant code is going to be replaced in upcoming refactors / in handling of other issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK
Awesome, thanks! |
Gocyclo is a code complexity linter. It uses cyclomatic complexity.
Cyclomatic complexity essentially measures the number of different
paths code could go through. (The conditional in a for loop counts
as adding one path) It looks at this on a per-function level. The
idea that this would be enforcing is that if there are too many
different paths code can go through in a function, it needs to be
better split up. (A function with too many code paths is hard to
reason about)
The complexity which we want the linter to start failing on is
configurable. The default is 10. Change the "Cyclo" parameter in
tools/gometalinter.json
to try other values.I've left the errors in this first commit, just so everyone can take a look. (Plus
its likely I don't understand most of the functions well enough to effectively
split them into smaller functions)
Wrote tests