Skip to content

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

Open
@adi-pen

Description

@adi-pen

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions