Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add new `Style/MultilineMemoization` cop #3604
This cop checks that multiline memoizations are wrapped in a
This only affects nodes that use parentheses, e.g.
Before submitting the PR make sure the following are checked:
Why this cop recommends
And I can't find performance issues.
begin_end = RubyVM::InstructionSequence.compile(<<-RUBY).to_a foo ||= begin 1 end RUBY brace = RubyVM::InstructionSequence.compile(<<-RUBY).to_a foo ||= ( 1 ) RUBY p begin_end == brace # => true
I think the style should be selectable by rubocop.yml. What do you think?
Style/MultilineMemoization: EnforcedStyle: begin_end SupportedStyles: - begin_end - brace
If the cop allows
# Can convert brace style. foo ||= begin bar end # Can't convert brace style! foo ||= begin bar rescue do_something end
This is in line with the convention of not using
A lot of cops don't have entries in the style guide. I would be open to try and get this adopted, though.
Yes. It's exclusively a style cop.
If there are people actually using the brace style, I am open to adding it.