You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since golang has the if err !=nil { return err } way of handling errors, it may be a nice touch to not increment the complexity when using the idiomatic golang error checking implementation.
This is just a proposition.
The text was updated successfully, but these errors were encountered:
Gocognit calculates complexity based on the paper, I'm not trying to bring new way to calculate cognitive complexity.
Not every language is the same, for example Go language has several feature that not defined on the paper, so that we might consider the complexity calculation for it, such as select statement.
I do understand Go use "err checking and return" instead of throw exception. Which means it easy for Go to have complexity higher compare to language that has exception handling. But again, the cognitive load of our brains is the same like we read another if statement, it is the same if, nothing special.
Sometimes inside the if body it has logging inside, or do some action before return the err. Sometimes is not a simple return error, but it need to return another value as well. There is nothing special, and it might still require the same cognitive load inside our brain.
I very appreciate. I promise nothing, but let me consider this.
I'm open if you want to have a discussion on this. Or PoC/PR would be very welcome.
Nice project !
Since golang has the
if err !=nil { return err }
way of handling errors, it may be a nice touch to not increment the complexity when using the idiomatic golang error checking implementation.This is just a proposition.
The text was updated successfully, but these errors were encountered: