-
Notifications
You must be signed in to change notification settings - Fork 153
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
WMC for conditional statements #31
Comments
Hi, @aaghamohammadi! Sorry for the slow reply. For some reason, I never got an email about your issue. You have definitely a good point. For now, the WMC calculation in the tool is basically "a count" of specific instructions, e.g., && and || in ifs, etc. Apparently, it's not working well for inline instructions. I'll work on that! Keep you posted! |
Dear @mauricioaniche, Thank you for your reply. I have another issue with Cyclomatic Complexity. It ignores nesting complexity. For example, When developers apply a popular refactoring method named "Replace Nested Conditional with Gaurd Clauses" (link), the structure of the source code really improves. However, the CC metric (by definition) does not change. Some researchers have proposed a few solutions. Surprisingly, the best solution (in my opinion) has the minimum citation (link). |
@aaghamohammadi Can you open another issue for this second suggestion (a concrete example like the one you provided here is very useful!)? So that we don't mix the discussions. |
@mauricioaniche Done. |
Still working on it. To differentiate between I, however, improved a lot the WMC, by adding a lot of tests, and fixing some bugs in very specific corner cases. Note that |
Changing the label here, as this is not a bug anymore, but an enhancement. |
@mauricioaniche |
Oh, I see what you mean. Sorry for my mistake, you definitely need some semantic analysis. |
I'll keep this one open... Maybe we'll find a simple way to do this semantic check. |
Hello,
I think there is a problem in calculating the WMC metric based on cyclomatic complexity.
For example, consider the following methods:
All these three methods do the same thing. However, the WMC complexities for m1,m2, and m3 are 3,2, and 2 respectively. In fact, the following inline conditional statement
does not increase CC complexity at all. Furthermore, when a condition becomes compact such as
you increase CC complexity just by one. I know the original paper does not take into account situations like that. However, don't you think it would be better to consider that?
The text was updated successfully, but these errors were encountered: