-
-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Description
Expected behavior
The cop's autocorrection should not break code.
Actual behavior
The cop's autocorrection breaks code.
Steps to reproduce the problem
The following code runs:
# frozen_string_literal: true
module MyNamespace
class MyClass
end
end
prefix = 'MyNamespace::'
class_name = 'MyClass'
Kernel.const_get("#{prefix}#{class_name}")
Running rubocop on it transforms it to this:
# frozen_string_literal: true
module MyNamespace
class MyClass
end
end
prefix = 'MyNamespace::'
class_name = 'MyClass'
Kernel.const_get(:"#{prefix}#{class_name}")
Running the corrected code produces the following error:
app.rb:10:in `const_get': wrong constant name MyNamespace::MyClass (NameError)
Kernel.const_get(:"#{prefix}#{class_name}")
^^^^^^^^^^
from app.rb:10:in `<main>'
RuboCop version
1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.1.1) [x86_64-linux]
- rubocop-performance 1.20.0
mikdiet and mscrivo
Metadata
Metadata
Assignees
Labels
No labels