A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/14346 below:

Unsafe autocorrection with Style/SingleLineMethods with a calculation · Issue #14346 · rubocop/rubocop · GitHub

When I run the autocorrection for Style/SingleLineMethods on the following line, it does a breaking change:

def notification_attributes() [:email] + editable_fields - [:message] end
Expected behavior

I'm expecting the autocorrect to output the following:

def notification_attributes = [:email] + editable_fields - [:message]
Actual behavior

But I get the following:

def notification_attributes = [:email] + editable_fields.-([:message])

The dot after editable_fields breaks the code.

Steps to reproduce the problem
# app/models/task.rb
class Task
  def notification_attributes() [:email] + editable_fields - [:message] end
end

Then run:

bundle exec rubocop -a app/models/task.rb
RuboCop version
$ bundle exec rubocop -V
1.77.0 (using Parser 3.3.8.0, rubocop-ast 1.45.1, analyzing as Ruby 3.2, running on ruby 3.2.8) [arm64-darwin24]
  - rubocop-capybara 2.22.1
  - rubocop-factory_bot 2.27.1
  - rubocop-performance 1.25.0
  - rubocop-rails 2.32.0
  - rubocop-rspec 3.6.0
  - rubocop-rspec_rails 2.31.0

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4