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

Rubocop (Rails/SaveBang) linters create(my_dynamic_string.to_sym) when using with dynamic first param #1620

Open
MarionCrp opened this issue Jan 26, 2024 · 0 comments
Labels

Comments

@MarionCrp
Copy link

Description

I apologies first if I'm not in the right place to ask/report.

I got the Rubocop Rails/SaveBang error triggered when I want to create FactoryBot object, using a dynamic value as first parameter.
See the Rubocop linter in the following
image

✅ Using with trait create(document_type, :my_trait)
✅ Using with public_send FactoryBot.public_send(:create, document_type)
❌ Using only the dynamic first param create(document_type)

Is it like Rubocop think I'm working with ActiveRecord object 😅

Thank you very much in advance for your help 🙏🏼

Reproduction Steps

Written script :

let(:instance_set_with_dynamic_class) { create(document_type) }
let(:instance_set_with_symbol) { create(:invoice) }
let(:instance_set_with_dynamic_class_with_trait) { create(document_type, :my_trait) }
let(:instance_set_with_symbol2) { FactoryBot.public_send(:create, document_type) }

Expected behavior

I would like Rubocop to not treat this as an ActiveRecord object (user.create(...) VS FactoryBot create(:user))
And not linter my line.

System configuration

factory_bot version: 6.4.5
rails version: 7.0.8
ruby version: 3.2.2

@MarionCrp MarionCrp added the bug label Jan 26, 2024
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

1 participant