Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Fixes Metrics/CyclomaticComplexity #8149
This PR fixes CyclomaticComplexity for
Blocks are tricky as some blocks clearly add to the complexity
Other builtin methods don't actually add to the cyclomatic
As @jonas054 pointed out, others methods in general can not be known.
This PR takes the conservative approach and counts only known iterating/conditional methods and ignores the rest.
If the default for CyclomaticComplexity remains at 6, there would be 34 new todos in the main gem.
I'm proposing to bump it to 7.
I was about to merge this and noticed that while this was counting
# cop/style/empty_case_condition.rb def on_case(case_node) return if case_node.condition return if case_node.when_branches.any? do |when_branch| when_branch.each_descendant.any?(&:return_type?) end if (else_branch = case_node.else_branch) return if else_branch.return_type? || else_branch.each_descendant.any?(&:return_type?) end add_offense(case_node, location: :keyword) end
I'm ok with this being counted as "complex". I couldn't help it and refactored it
Howdy guys, you've recently introduced "pending" cops to reduce the risk of breaking pipelines and however you're updating the cyclo calculation that's my humor.
I don't want to criticize the decision about the new default value (and how it's be fallen), but although it introduces "only" 5 changes for you guys, we have dozens of pipelines failing due to that change. And increasing the value even further to have less work is no option for us.
I guess the problem here is that the changes were considered a bug-fixes, not a behaviour change (although they do change the behaviour). The new default itself is not a problem in itself, as it was actually relaxed, so for me the problem is how to communicate better bug-fixes that would probably result in broken pipelines. Sometimes we're aware that a breakage is likely to occur (e.g. in this case), but some things would be a surprise even to us.
I'm not sure what's the best course of action here.
@tonobo: Really sorry it's causing you trouble. I understand it can be frustrating to have code that previously was ok to now be causing offenses. I had hoped that this change would land in v1.
Are you aware that