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

Style/MultilineMemoization autocorrects to invalid ruby #4322

Closed
nikolai-b opened this issue Apr 27, 2017 · 3 comments · May be fixed by LemonSpike/Xcodeproj#4
Closed

Style/MultilineMemoization autocorrects to invalid ruby #4322

nikolai-b opened this issue Apr 27, 2017 · 3 comments · May be fixed by LemonSpike/Xcodeproj#4
Labels

Comments

@nikolai-b
Copy link

Expected behavior

Style/MultilineMemoization auto-corrects when the ( are not on new lines by replacing them with begin

Actual behavior

If ( is not on its own line then a new line should be added.

Steps to reproduce the problem

Autocorreting

class MyClass
  def my_method
    @my_method ||= (true ||
                    true ||
                    false)
  end
end

becomes

class MyClass
  def my_method
    @my_method ||= begintrue ||
                    true ||
                    falseend
  end
end

RuboCop version

$ rubocop -V
0.43.0 (using Parser 2.4.0.0, running on ruby 2.2.4 x86_64-linux)
nikolai-b added a commit to nikolai-b/rubocop that referenced this issue Apr 27, 2017
@bbatsov bbatsov added the bug label Apr 28, 2017
@ilansh
Copy link
Contributor

ilansh commented May 16, 2017

I'm looking into fixing this.
Assuming the expected result would be (correct me if I'm wrong):

class MyClass
  def my_method
    @my_method ||= begin
      true ||
      true ||
      false
    end
  end
end

Should the cop also fix the indentation of items in the expression, or is it ok to let other cops fix it?

@Drenmi
Copy link
Collaborator

Drenmi commented May 16, 2017

@ilansh: Basic indentation is generally handled by each individual cop's autocorrect. 🙂

@nikolai-b
Copy link
Author

@ilansh I've got a PR open in #4323 but I wasn't sure how best to do the indentation.

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

Successfully merging a pull request may close this issue.

4 participants