rubocop / rubocop/ruby-style-guide
assignment in conditional ternary
Open
Nobody has claimed this yet.
New Rule
- Dominant language
- No language data
- Stars
- 16.5k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Description
Should assignment in conditional ternary be avoided ?
something like this
condition ? self.foo = bar : self.foo2 = bar2
it's dealing with operator precedence and it is less clear than
if condition
self.foo = bar
else
self.foo2 = bar2
end
that we are modifying some state
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
Review the style guide's current guidance on ternary expressions and assignments, then compare it with the two Ruby examples in this issue. Determine whether the guide should address assignments in conditional ternaries and make the resulting recommendation explicit, with examples that clearly resolve the construct.
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
- 45/100