Closed kalessil closed 6 years ago
small :-1: for that, it can make code less readable, and may be problematic with nested ternary operators
then, if one have condition foo() && bar() || baz()
, splitting this into 3 lines would make code coverage more precise, wouldn't it?
coverage metrics brings value, but it's not ultimate value to use (no metrics is), maybe instead of adjust codebase to be better handled by one metrics, add metrics that would bring more value - eg MSI (Mutation Score Indicator) ?
Complex conditions are certainly not =) MSI might help, ths for an idea. BTW, @keradus you can close the issue if it's doesn't fit the project direction - I'm fine with it.
I tend to refrain from closing requests out of the blue. I see the value of proposed rule, yet I simply think that this value can be achieved in other, better way ;) Glad you like it as well ;)
For that, I'm not closing this PR "right now", yet it's not on top of my prio list - let us hear the voice of community. If few guys will want this rule, and maybe even one of them will help with PR, I would merge such PR for sure ;)
I only apply this rule for long/hard to read lines so I won't use a fixer that blindy adds newlines to all ternary expressions. Maybe better with some kind of length detection, but probably tricky in some cases.
Closing: the MSI is the way to go here.
Not sure how soon I get time to contribute myself, so filing the feature request.
Goal: more precise test coverage numbers.
Source code fragment:
Target code fragment:
Complexity of true/false variants is not important, the variants should go to a new line always. In my case the nested ternary is taboo, so its' support is not needed.