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

Add the excessive_create_list FactoryBot cop #1737

Conversation

ddieulivol
Copy link

@ddieulivol ddieulivol commented Nov 9, 2023

Cop used to signal when we create a lot of factory objects with FactoryBot (configurable with the MaxAmount option).

        # @example MaxAmount: 10 (default)
        #   # We do not allow more than 10 items to be created
        #
        #   # bad
        #   create_list(:merge_request, 1000, state: :opened)
        #
        #   # good
        #   create_list(:merge_request, 10, state: :opened)
        #

Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Updated documentation.
  • Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

If you have created a new cop:

  • Added the new cop to config/default.yml.
  • The cop is configured as Enabled: pending in config/default.yml.
  • The cop is configured as Enabled: true in .rubocop.yml.
  • The cop documents examples of good and bad code.
  • The tests assert both that bad code is reported and that good code is not reported.
  • Set VersionAdded: "<<next>>" in default/config.yml.

If you have modified an existing cop's configuration options:

  • Set VersionChanged: "<<next>>" in config/default.yml.

Cop used to signal when we create a lot of
factory objects with FactoryBot (configurable
with the MaxAmount option)
@ddieulivol ddieulivol force-pushed the ddieulivol-factory_bot_excessive_create_list_cop branch from 255f7a6 to 3eedcf3 Compare November 9, 2023 14:23
Copy link
Member

@pirj pirj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, the cop looks good.
I’ve added notes, mostly minor and cosmetic.

We’ve moversxtracted all FB cops to https://github.com/rubocop/rubocop-factory_bot/tree/master/lib/rubocop/cop/factory_bot
Please retarget the PR there.

.rubocop.yml Show resolved Hide resolved
config/default.yml Show resolved Hide resolved
config/default.yml Show resolved Hide resolved
@pirj
Copy link
Member

pirj commented Nov 10, 2023

The failing spec tells that you have to add yourself in the bottom of the changelist, alphabetically.

@pirj
Copy link
Member

pirj commented Nov 10, 2023

@pirj pirj closed this Nov 10, 2023
@ddieulivol
Copy link
Author

This should go to https://github.com/rubocop/rubocop-factory_bot

New MR is at rubocop/rubocop-factory_bot#83

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

Successfully merging this pull request may close these issues.

2 participants