Closed DanielRuf closed 4 years ago
Can you provide context and reasoning for this change outside of "Ternaries are not clean code"? This feels more like a personal opinion rather than an objective fact.
Such ternaries are also hard to read.
I see no reason to introduce this outside of personal preference. Going to close, but thank you for the time/effort!
Not a personal preference but Clean Code.
I asked what "Clean Code" was before and you failed to answer, instead pivoting to a different reasoning. Repeating that same thing was never clarified probably isn't going to be a successful approach.
I see no comment here from me regarding going into detail about Clean Code ;-)
This was probably another issue / project.
SonarQube, linting rules and other tools often propose if-else instead of a (longer) ternary.
https://stackoverflow.com/a/160295/753676
Either we reformat (newlines is often better than one one line) or we replace it with a better readable if-else ;-)
Sorry that I had not much more time to go into detail, too many other things todo.
Can you provide context and reasoning for this change outside of "Ternaries are not clean code"?
https://github.com/cutenode/good-first-issue/pull/141#issuecomment-521848605
As I already wrote, I probably forgot to go into further detail ;-)
Such ternaries are also hard to read.
This is one of the reasons why ternaries are often bad. At least when they are only on one line ;-)
Would it be ok if I would make it multiline? Makes it easier to see both cases.
SonarQube, linting rules and other tools often propose if-else instead a (longer) ternary.
This project uses Standard, which does not enforce this rule. "Someone else prefers to do it another way" is not a compelling argument.
I won't be merging PRs around changing the ternary. There has still been no objective reason presented outside of personal preference.
OK =)
Just for reference: https://eslint.org/docs/rules/multiline-ternary
Would be easier to read imo. Just my two cents.
(But :
and ?
at the start of the lines is often better).
Ternaries are not clean code. Use normal if statements to handle this.