profile
viewpoint

Ask questionsRequest: Style/RedundantBegin should ignore usage for memoization

This is a feature request / suggestion for the Style/RedundantBegin cop.

It would be nice if this cop could ignore begin when used in assignment, particularly for memoization. I often write code like this, and use begin to control the amount of indentation.

  def number_of_cats
    @number_of_cats ||= begin
      count = calucate_number_of_cats.munge_the_number
                                     .more_munging
      count -= 1 if zero_based_cats?
      count
    end
  end

RuboCop version

bundle exec rubocop -V
1.15.0 (using Parser 3.0.1.1, rubocop-ast 1.5.0, running on ruby 2.6.6 x64-mingw32)
  - rubocop-rails 2.10.1
rubocop/rubocop

Answer questions pauldruziak

@koic you are right, thanks

useful!
source:https://uonfu.com/
Github User Rank List