Skip to content

non-idempotent formatting for overlong parenthesized inline conditionals #829

@froydnj

Description

@froydnj

Commit: 0e63875

Input

→ View on rubyfmt.run

# original input
module X
  class Y
    module More
      def test
        # comments make a difference?
        amount = amount_from_api ||
          (Opus::MonetaryFlows::Private::API::BeesItems::ParamTransformer.validation_amount(line_items) if !line_items.nil?)
      end
    end
  end
end

# formatted input from the above
# ought to have been idempotently formatted
module X
  class Y
    module More
      def test
        # comments make a difference?
        amount = amount_from_api ||
          (Opus::MonetaryFlows::Private::API::BeesItems::ParamTransformer.validation_amount(line_items) if !line_items
            .nil?)
      end
    end
  end
end

Output

# original input
module X
  class Y
    module More
      def test
        # comments make a difference?
        amount = amount_from_api ||
          (Opus::MonetaryFlows::Private::API::BeesItems::ParamTransformer.validation_amount(line_items) if !line_items
            .nil?)
      end
    end
  end
end

# formatted input from the above
# ought to have been idempotently formatted
module X
  class Y
    module More
      def test
        # comments make a difference?
        amount = amount_from_api ||
          (if !line_items
              .nil?
            Opus::MonetaryFlows::Private::API::BeesItems::ParamTransformer.validation_amount(line_items)
          end)
      end
    end
  end
end

Expected behavior

Idempotent formatting. Looks like a variant of #813 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions