-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Expected behavior
For example, when running autocorrect with the following configuration:
Style/AccessorGrouping:
EnforcedStyle: separated
# frozen_string_literal: true
class Foo
attr_reader :a, # a
:b # b
end
In this case, the expected change was as follows:
# frozen_string_literal: true
class Foo
# a
attr_reader :a
# b
attr_reader :b
end
Actual behavior
The trailing comment ends up duplicated as shown below:
# frozen_string_literal: true
class Foo
# a
attr_reader :a
# b
attr_reader :b # b
end
It seems that when the original code spans multiple lines without parentheses, the trailing comment gets duplicated.
Steps to reproduce the problem
The issue can be easily reproduced by running autocorrect with the code and configuration described above.
RuboCop version
$ bundle exec rubocop -V
1.78.0 (using Parser 3.3.8.0, rubocop-ast 1.45.1, analyzing as Ruby 2.7, running on ruby 3.4.2) [x86_64-linux]
- rubocop-performance 1.25.0
- rubocop-rake 0.7.1
- rubocop-rspec 3.6.0