rubocop / rubocop/ruby-style-guide
Ternary branch text seems too strong
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 16.5k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Description
Use one expression per branch in a ternary operator. This also means that ternary operators must not be nested.
So apparently you're counting subexpressions and thus these are considered bad:
i ? t + 1 : e # Three expressions in true-branch: t, 1 and t + 1
i ? f(t) : e # Two expressions in true-branch: t and f(t)
x < 0 ? -x : x # Two expressions in true-branch: x and -x
Is that really intended? If so, I think it would be good to include them as "bad" examples. If not, then I think the wording should be improved.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked No nested ternary section in the Ruby Style Guide and review the wording against the examples in this issue. Determine whether the current rule intentionally rejects those expressions; once that is settled, update the wording or add representative bad examples.】【。
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100