-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Cop idea: detect stub_const that doesn't refer the const #423
Comments
The issue happens only when In my projects, I have a rule of never using nested stubbing without first requiring the “outer” constants. I don’t think we can enforce such a rule with static analysis alone. @dgollahon may know more – perhaps a job for RSpectre? |
ping @dgollahon |
I personally avoid this by just requiring all constants upfront. Regarding Maybe That said, I think it would be a good addition to |
When someone uses
stub_const('Foo::BAZ', 42)
, all other constants (and methods) defined in Foo may be lost. This is explained in rspec/rspec-mocks#1079. I've lost couple of hours debugging it the first time it happened to me, and since then few times returned such stubs at a code review. It would be nice to have a cop that warns about this behavior.The text was updated successfully, but these errors were encountered: