When running rubocop -a foo.rb
with the following .rubocop.yml
:
AllCops: NewCops: enable TargetRubyVersion: 3.4
and foo.rb
is the following file:
# frozen_string_literal: true foo = Object.new def foo.bar; 'baz'; end puts foo.bar
I expect RuboCop to maintain the existing behavior when safe autocorrecting.
Before running rubocop -a foo.rb
, running ruby foo.rb
just outputs:
After running rubocop -a foo.rb
, foo.rb
is:
# frozen_string_literal: true foo = Object.new def bar = 'baz' puts foo.bar
Now 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 -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]
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