You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
…omparison`
Fixesrubocop#12097.
This PR marks unsafe autocorrect for `Style/ClassEqualityComparison`
because there is no guarantee that the constant `Foo` exists when
autocorrecting `var.class.name == 'Foo'` to `var.instance_of?(Foo)`.
Fixes#12097.
This PR marks unsafe autocorrect for `Style/ClassEqualityComparison`
because there is no guarantee that the constant `Foo` exists when
autocorrecting `var.class.name == 'Foo'` to `var.instance_of?(Foo)`.
It is not safe to autocorrect
foo.class.name == 'Bar'
tofoo.instance_of?(::Bar)
because::Bar
may not be defined.Expected behavior
The Style/ClassEqualityComparison cop autocorrect shouldn't be marked as safe because the autocorrected code may cause
NameError
.Actual behavior
foo.class.name == 'Bar'
is autocorrected tofoo.instance_of?(::Bar)
.Steps to reproduce the problem
Create a file with
foo.class.name == 'Bar'
and runrubocop -a
.RuboCop version
1.55.1
The text was updated successfully, but these errors were encountered: