Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style/ClassEqualityComparison autocorrect bug when comparing to Class.name #9745

Closed
ghiculescu opened this issue Apr 28, 2021 · 1 comment
Closed

Comments

@ghiculescu
Copy link
Contributor

Input:

foo.class.name == Bar.name

Output:

app/untitled.rb:1:5: C: [Correctable] Style/ClassEqualityComparison: Use instance_of?(Bar.name) instead of comparing classes.
foo.class.name == Bar.name
    ^^^^^^^^^^^^^^^^^^^^^^

Autocorrect gives this:

foo.instance_of?(Bar.name)

Which is invalid, and causes instance_of? to throw a TypeError. It should autocorrect to

foo.instance_of?(Bar)

RuboCop version

1.10.0 (using Parser 3.0.0.0, rubocop-ast 1.4.1, running on ruby 2.7.3 x86_64-darwin19)
  - rubocop-minitest 0.10.3
  - rubocop-rails 2.9.1
@koic
Copy link
Member

koic commented Apr 28, 2021

This issue is a dup with #8875 and resolved by #8876. Please update to the latest RuboCop (1.13.0). Thank you.

@koic koic closed this as completed Apr 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants