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

FactoryBot/FactoryNameStyle thinks that Rails generate is a factory_bot method. #3

Closed
jcoyne opened this issue Feb 27, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@jcoyne
Copy link

jcoyne commented Feb 27, 2023

This is a Rails built in method: https://guides.rubyonrails.org/generators.html#generate

RSpec/FactoryBot/FactoryNameStyle: Use symbol to refer to a factory.
    generate 'blacklight:install', '--devise'
             ^^^^^^^^^^^^^^^^^^^^

This is not a factory, and when it is autocorrected, the generator doesn't run correctly.

@jcoyne jcoyne changed the title RSpec/FactoryBot/FactoryNameStyle thinks that Thor generate is a factory_bot method. RSpec/FactoryBot/FactoryNameStyle thinks that Rails generate is a factory_bot method. Feb 27, 2023
@tejasbubane
Copy link
Contributor

tejasbubane commented Mar 27, 2023

@jcoyne This is one of the false positives of this cop which I think we cannot fix easily. Easiest would be to disable cop on this line or restrict RSpec/FactoryBot/FactoryNameStyle to specific directories.

@jcoyne
Copy link
Author

jcoyne commented Mar 27, 2023

@tejasbubane That cop seems prone to giving incorrect advice. Maybe this cop should not be enabled by default.

@ydah ydah transferred this issue from rubocop/rubocop-rspec May 6, 2023
@ydah ydah changed the title RSpec/FactoryBot/FactoryNameStyle thinks that Rails generate is a factory_bot method. FactoryBot/FactoryNameStyle thinks that Rails generate is a factory_bot method. May 6, 2023
@ydah ydah added the bug Something isn't working label May 9, 2023
@pirj
Copy link
Member

pirj commented May 15, 2023

You should disable FactoryBot/FactoryNameStyle in generator specs using the following in spec/generators/.rubocop.yml:

FactoryBot/FactoryNameStyle:
  Enable: false

Or to exclude certain directories from the project .rubocop.yml file:

FactoryBot/FactoryNameStyle:
  Exclude:
    - "**/spec/generators/**/*.rb"

@pirj pirj closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants