-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Expected behavior
When running rubocop -a foo.rb with the following .rubocop.yml:
AllCops:
NewCops: enable
TargetRubyVersion: 3.4and foo.rb is the following file:
# frozen_string_literal: true
foo = Object.new
def foo.bar; 'baz'; end
puts foo.barI expect RuboCop to maintain the existing behavior when safe autocorrecting.
Before running rubocop -a foo.rb, running ruby foo.rb just outputs:
baz
Actual behavior
After running rubocop -a foo.rb, foo.rb is:
# frozen_string_literal: true
foo = Object.new
def bar = 'baz'
puts foo.barNow running ruby foo.rb outputs:
foo.rb:5:in '<main>': private method 'bar' called for an instance of Object (NoMethodError)
puts foo.bar
^^^^
Steps to reproduce the problem
Run rubocop -a foo.rb where foo.rb is the above file.
RuboCop version
> rubocop -V
1.78.0 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.45.1, analyzing as Ruby 3.4, running on ruby 3.4.4) [arm64-darwin24]