Skip to content

Conversation

Mth0158
Copy link
Contributor

@Mth0158 Mth0158 commented Jul 31, 2025

Fixes #2093

@pirj as discussed

Reading the code, thanks to your help, I noticed that it might be preferable to exclude factorybot files from inspection. From my understanding, all the cops, except 2 (Metrics/BlockLength and RSpec/RemoveConst), are relevant for inspecting these files.

I have included the 2 that are relevant apply to factorybot with the include inherit_method.

Unsure about how to add tests for these? I read the test and decided it was not necessary to add some but let me know what you expect if so?

Let me know what you think.

@Mth0158 Mth0158 requested a review from a team as a code owner July 31, 2025 12:35
@Mth0158 Mth0158 force-pushed the factorybot-wrong-interpretation-of-attribute-as-example-declaration branch from feb6ade to 1d49a0a Compare July 31, 2025 12:35
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!

Reference: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/RemoveConst
inherit_mode:
merge:
- Include
Copy link
Member

Choose a reason for hiding this comment

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

It seems unlikely to have remove_const in factories. Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't 100% sure of the use for this cop, let's remove it. I have never done a remove_const in Rspec

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.

Fantastic, thank you! 🙌

Copy link
Collaborator

@bquorning bquorning left a comment

Choose a reason for hiding this comment

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

Let’s squash down to 1 commit, and merge 👏🏼

@pirj pirj force-pushed the factorybot-wrong-interpretation-of-attribute-as-example-declaration branch from 16718f5 to 0b86050 Compare August 4, 2025 16:39
@pirj pirj merged commit 09f60c7 into rubocop:master Aug 4, 2025
27 checks passed
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.

[FactoryBot] Wrong interpretation of attribute as example declaration

4 participants