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

Incorrect autocorect for RSpec/StringAsInstanceDoubleConstant #1965

Open
jcoyne opened this issue Oct 7, 2024 · 2 comments
Open

Incorrect autocorect for RSpec/StringAsInstanceDoubleConstant #1965

jcoyne opened this issue Oct 7, 2024 · 2 comments
Labels

Comments

@jcoyne
Copy link

jcoyne commented Oct 7, 2024

When I run the autocorrect for RSpec/StringAsInstanceDoubleConstant, it just changes the string to a constant. However, this constant doesn't exist. It would be better to just say it's not autocorrectable, or just make it a double (not instance_double)

-      let(:api_response) { instance_double('Response', status: 204, content_type: :json) }
+      let(:api_response) { instance_double(Response, status: 204, content_type: :json) }
@ydah ydah added the bug label Oct 21, 2024
@pirj
Copy link
Member

pirj commented Nov 8, 2024

We plan to remove this cop as it duplicates another cop.

As you point out, if the constant is fake, the correction should be to use double.

Do you have issues with the other cop?
We were discussing the removal of “string” as a valid enforced style. Do you happen to use it? Would you agree to this?

@jcoyne
Copy link
Author

jcoyne commented Nov 8, 2024

My major concern is that it's not auto-correctable. I don't think even unsafe autocorrect should be attempted. I do think prohibiting any non-constant should be flagged on instance_double though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants