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
Complexity rule prefers and &&
over or ||
#8535
Complexity rule prefers and &&
over or ||
#8535
Comments
There seems to be hardcoded logic in the rule that well only increase complexity for So it is working as intended. I think the logic is saying that since an |
Closing because this seems to be working as intended. |
No it is not : See @soda0289 statement :
Also according to Wikipedia :
So this means that to count the complexity, we need to change our program to remove the "or" and "and", that would be :
=>
Complexitiy = 1 + number of if statements = 1+2 = 3 For check3 :
Complexity = 1 + number of if statements = 3. So please, reopen this issue :-) |
I think I agree. Assuming a negation does not count towards cyclomatic complexity, by DeMorgan's law it is always the case that I'm convinced this is a bug. @soda0289 @not-an-aardvark Okay if I reopen? |
Ok, sounds good. |
Do you think we should add an option to count |
I just found this: jshint/jshint#840 If I had to guess, this bug exists because we were originally mimicing/copying the logic from JSHint, but JSHint also had a bug in the logic related to |
Marking this accepted because I'm also now convinced that this is a bug. |
What parser (default, Babel-ESLint, etc.) are you using? : babel-eslint
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
All functions check to check5 should have the same complexity
What actually happened? Please include the actual, raw output from ESLint.
It seems that
||
has more complexity than&&
in the current implementation, but I don't think that is true. All thecheck
have a complexity of 3. (That is what http://jsmeter.info/axtsgb/1#results reports)The text was updated successfully, but these errors were encountered: