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

Disable Rubocop rule: Style/MultilineBlockChain #906

Closed
3 of 5 tasks
Hansenq opened this issue Jun 20, 2021 · 3 comments
Closed
3 of 5 tasks

Disable Rubocop rule: Style/MultilineBlockChain #906

Hansenq opened this issue Jun 20, 2021 · 3 comments

Comments

@Hansenq
Copy link
Contributor

Hansenq commented Jun 20, 2021

Metadata

  • Ruby version: 3.0.0
  • @prettier/plugin-ruby or prettier gem version: 1.5.5
  • Options:
    • rubyHashLabel
    • rubyModifier
    • rubySingleQuote
    • rubyToProc
    • trailingComma

Current output

This code is the prettified output:

          Artist.where(name: names).select(:name).select_more do
            max(:id).as(:id)
          end.group(:name)

Running rubocop on the code above unfortunately returns the following error (this rule is enabled by default):

C: Style/MultilineBlockChain: Avoid multi-line chains of blocks.

We should disable Style/MultilineBlockChain in the plugin-ruby rubocop configuration.

@kddnewton
Copy link
Member

As of latest main this will result in:

Artist
  .where(name: names)
  .select(:name)
  .select_more { max(:id).as(:id) }
  .group(:name)

which shouldn't violate the rubocop rule.

@bentwistbsc
Copy link

bentwistbsc commented Oct 20, 2021

@kddnewton
It seems that there is still an issue with the latest version:
The prettified output of this code:

my_hash
  .map { |my_key, my_long_value| { this_is_the_type: my_key, this_is_the_value: my_long_value } }
  .filter { |item| item[:this_is_the_value].present? }

Would be:

my_hash
  .map do |my_key, my_long_value|
    { this_is_the_type: my_key, this_is_the_value: my_long_value }
  end
  .filter { |item| item[:this_is_the_value].present? }

Which results in RuboCop: Avoid multi-line chains of blocks. [Style/MultilineBlockChain]

@kddnewton
Copy link
Member

@bentwistbsc fair enough. I just pushed up disabling Style/MultilineBlockChain in the shipped config, that'll be out in the next release.

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

Successfully merging a pull request may close this issue.

3 participants