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 FactoryBot/AssociationStyle cop #33

Merged
merged 6 commits into from May 15, 2023
Merged

Conversation

r7kamura
Copy link
Contributor

@r7kamura r7kamura commented May 8, 2023

Recreated from the following pull request:


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 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.

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.

Looks great, thank you!
I've applied some cosmetic clean-up.

lib/rubocop/cop/factory_bot/association_style.rb Outdated Show resolved Hide resolved
lib/rubocop/cop/factory_bot/association_style.rb Outdated Show resolved Hide resolved
lib/rubocop/cop/factory_bot/association_style.rb Outdated Show resolved Hide resolved
@pirj
Copy link
Member

pirj commented May 14, 2023

lib/rubocop/cop/factory_bot/association_style.rb:174:25: C: InternalAffairs/UndefinedConfig: NonImplicitAssociationMethodNames is not defined in the configuration for FactoryBot/AssociationStyle in config/default.yml.
            (cop_config['NonImplicitAssociationMethodNames'] || [])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Locally 🧐

$ rubocop -v
v1.50.2

Updated to the latest 1.51.0, but still the same. It seems to be a rubocop bug to me.
Green on ci, so no problem.

PS most probably caused by rubocop-rspec's config somehow being preferred over rubocop-factory_bot's one, as witnessed by such messages:

/Users/pirj/.rvm/gems/ruby-3.1.0@rubocop-factory_bot/gems/rubocop-rspec-2.20.0/config/default.yml: FactoryBot/FactoryNameStyle has the wrong namespace - should be RSpec/FactoryBot

Copy link
Member

@ydah ydah 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!

@pirj
Copy link
Member

pirj commented May 15, 2023

@ydah Are you ok with this?
We can merge and release everything we have stacked up in a minor version, as it's the last PR remaining.

Copy link
Member

@ydah ydah 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!

@pirj pirj merged commit 6054f30 into rubocop:master May 15, 2023
20 checks passed
@pirj
Copy link
Member

pirj commented May 15, 2023

Thank you, @r7kamura ! :combo: 1️⃣ 2️⃣ 3️⃣ 🥇

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.

None yet

3 participants