rubocop / rubocop/ruby-style-guide

what to do when if conditions too long?

Open
#476 13 comments 21 reactions 0 assignees View on GitHub

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

Which syntax is preferred for multi line conditions on if, like when the conditions are too long that they over 80 chars limit

if some.long.method && other_condition && another_condition
  do_something
  do_something_else
end

my guess is
normal indent

if some.long.method && 
  other_condition && 
  another_condition
  do_something
  do_something_else
end

or double indent

if some.long.method && 
    other_condition && 
    another_condition
  do_something
  do_something_else
end

i think the second one is more readable
or anyone have better idea?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no file, test, or entry point. Review the existing Ruby style guide guidance and the unresolved discussion about multiline if conditions; this is done when the project agrees on a preferred convention and documents it with representative examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.