-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Additional Option for Cyclomatic Complexity #1220
Comments
@jasonmk I think that, broadly speaking, cyclomatic complexity is a metric that tells you how difficult is this to test. What you're looking for is slightly different, how difficult is this to read. So if we're going to add this configuration option, it's probably best to create a new cop for it, because without the @bbatsov @yujinakayama What do you think about adding a |
👍 for |
Awesome, that sounds great. |
👍 for |
Move the Style cops BlockNesting, ClassLength, CyclomaticComplexity, MetricsLineLength, MethodLength, and ParameterLists to the new namespace.
Just want to add my two cents. While it's true that the classic cyclomatic complexity is a strict metric of testability, practical applications have led to the creation of its variant, modified complexity. Modified cyclomatic complexity is almost exactly the same as the classic cyclomatic complexity, except that a switch statement only increases the value by 1 regardless of how many case statements it contains. A number of other code analysis tools implement this metric. See:
Given that it's common enough in the industry, I propose that you still consider adding an option to the existing cyclomatic complexity rule, or accepting a PR for a separate Modified Complexity rule (it'll probably just inherit from the existing Cyclomatic Complexity rule). Note that this is still different from the PerceivedComplexity rule that now exists. I'd be happy to make a contribution either way. What do you think? |
I'd like to see an option for Cyclomatic Complexity that allows me to ignore 'when' statements when computing the complexity of a method. Basically, any method with a case statement is virtually guaranteed to exceed the Complexity limit. If I only had 1 or two possible conditions, I'd probably be using if/elsif/else anyways. Case statements are great for a method that branches off into a number of different paths, but that doesn't make it inherently complex.
The text was updated successfully, but these errors were encountered: