Skip to content

Relatively short method chain with hash passed last breaks chain on multiple lines #729

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

Closed
rafbm opened this issue Dec 15, 2020 · 0 comments · Fixed by #740
Closed

Relatively short method chain with hash passed last breaks chain on multiple lines #729

rafbm opened this issue Dec 15, 2020 · 0 comments · Fixed by #740

Comments

@rafbm
Copy link

rafbm commented Dec 15, 2020

Removing one method call, eg. changing the line to config.action_dispatch.merge! does not produce this behavior. Not sure if this follows a generally accepted “max chained method calls on a single line” guideline which I’m not aware of?

Metadata

  • Ruby version: 2.6.6p146
  • @prettier/plugin-ruby or prettier gem version: 1.0.1
  • Options: All current defaults.

Input

module Missive
  class Application < Rails::Application
    config.action_dispatch.rescue_responses.merge!(
      # We created more threads than RAILS_MAX_THREADS
      'ActiveRecord::ConnectionTimeoutError' => :service_unavailable,
      # Some query hits a timeout
      'ActiveRecord::QueryCanceled' => :service_unavailable,
      # Rack::Timeout
      'Rack::Timeout::RequestExpiryError' => :service_unavailable,
      'Rack::Timeout::RequestTimeoutError' => :service_unavailable,
      'Rack::Timeout::RequestTimeoutException' => :service_unavailable,
    )
  end
end

Current output

module Missive
  class Application < Rails::Application
    config
      .action_dispatch
      .rescue_responses
      .merge!(
        # We created more threads than RAILS_MAX_THREADS
        'ActiveRecord::ConnectionTimeoutError' => :service_unavailable,
        # Some query hits a timeout
        'ActiveRecord::QueryCanceled' => :service_unavailable,
        # Rack::Timeout
        'Rack::Timeout::RequestExpiryError' => :service_unavailable,
        'Rack::Timeout::RequestTimeoutError' => :service_unavailable,
        'Rack::Timeout::RequestTimeoutException' => :service_unavailable
      )
  end
end

Expected output

module Missive
  class Application < Rails::Application
    config.action_dispatch.rescue_responses.merge!(
      # We created more threads than RAILS_MAX_THREADS
      'ActiveRecord::ConnectionTimeoutError' => :service_unavailable,
      # Some query hits a timeout
      'ActiveRecord::QueryCanceled' => :service_unavailable,
      # Rack::Timeout
      'Rack::Timeout::RequestExpiryError' => :service_unavailable,
      'Rack::Timeout::RequestTimeoutError' => :service_unavailable,
      'Rack::Timeout::RequestTimeoutException' => :service_unavailable,
    )
  end
end
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.

1 participant