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

Ignore idiomatic error checking #40

Open
MohammadBnei opened this issue Dec 12, 2024 · 1 comment
Open

Ignore idiomatic error checking #40

MohammadBnei opened this issue Dec 12, 2024 · 1 comment

Comments

@MohammadBnei
Copy link

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.

@uudashr
Copy link
Owner

uudashr commented Dec 17, 2024

Hi @MohammadBnei, thanks in advance.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants