Closed davidenglishmusic closed 8 months ago
I confirm this in ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]
too.
Hello 👋
Our project updated rubocop-performance today so we noticed this bug.
In addition to the autocorrect being unsafe, this rule matching on string interpolation at all seems (to me) to be incorrect. Rubocop is not able to determine if a string interpolation usage is indeed "redundant".
Hm, this is a bit unfortunate. The problem isn't the interpolation per se but just passing a symbol with doube colons in the first place. This on its own raises as well:
Kernel.const_get(:"MyNamespace::MyClass")
I'm actually not sure if this is intended on the side of ruby or not since I'm not finding documentation on this behaviour where I'd expect it. It doesn't seem to recurse if a symbol is given.
https://bugs.ruby-lang.org/issues/12319 I found this issue in Ruby core. In short, it's an intended behavior.
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:
Running rubocop on it transforms it to this:
Running the corrected code produces the following error:
RuboCop version