Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of do...end block syntax in conditionals #859

Open
adi-pen opened this issue Jan 6, 2021 · 1 comment
Open

Usage of do...end block syntax in conditionals #859

adi-pen opened this issue Jan 6, 2021 · 1 comment

Comments

@adi-pen
Copy link

adi-pen commented Jan 6, 2021

I encountered a situation where a do...end block syntax is used as a work-around to avoid line limits.

Example:

# frozen_string_literal: true

if [].any? do |variable|
  # do something
end
  true
end

Indenting the block by one level helps identify the end of the conditional easily but still does not feel natural at least to me. This results in a Layout/BlockAlignment offense.

# frozen_string_literal: true

if [].any? do |variable|
    # do something
  end
  true
end

Could we enforce that do..end blocks are not used in conditionals or have a style-preference if we support it?

@pirj
Copy link
Member

pirj commented Feb 25, 2021

Both exampes look extremely awkward.

Would you like to send a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants