3 ms·
Cyclomatic complexity seems difficult to lint. I tried, briefly, and decided that linters were much better more for catching mechanical problems than stylistic
by wolfgang42 10y ago
Cyclomatic complexity seems difficult to lint. I tried, briefly, and decided that linters were much better more for catching mechanical problems than stylistic ones. Where do you set the line? 10? What happens if you have a function that's got a complexity of 11? Do you have to split it? What if that makes the code harder to read?
Maybe this makes more sense in a codebase where there's a variety of contributors of differing skill levels. I'm interested to hear about how other people use measures of complexity and function size.
- partycoder 10y agoSure, you can create a Sorites paradox out of this... https://en.wikipedia.org/wiki/Sorites_paradox https://en.wikipedia.org/wiki/Sorites_paradox Eventually you will have to commit to an arbitrary value, and stick to it. But there are cases in which it's no longer subjective if cyclomatic complexity is bad. If you have a 500 lines of code function with 50 return points and cyclomatic complexity of 100 it is very clear there is no way you can maintain that or write a unit test for it without playing Russian roulette each time you check in a change and therefore you can objectively say that code is not safe and should not be allowed.