makandra / makandra-rubocop

makandra's default Rubocop configuration
MIT License
6 stars 1 forks source link

Add factory bot and capybara #46

Closed denzelem closed 5 months ago

denzelem commented 5 months ago

PR to add default configs for rubocop-factory_bot and rubocop-capybara (see #45). I decided to not add rubocop-rake, since it seems not be actively used anymore.

There are a few cops in the pending state. As far as I understand, we follow the approach of Rubocop to keep then on pending until the next major release and the community has decided to enable or disable a cop.

I added this config to a larger project and the changes were straight forward. I linked the PR for the larger project to this PR, so cops can be discussed here.

FLeinzi commented 5 months ago

I recently used this configuration on an customer project with its own rubocop fork (not makandra-rubocop).

Capybara

Capybara/ClickLinkOrButtonStyle:
  Enabled: true
  EnforcedStyle: strict

Capybara/MatchStyle:
  Enabled: true

# I prefer `not_to` but in the end it doesn't matter at all, so this cop could also be disabled.
Capybara/NegationMatcher:
  Enabled: true
  EnforcedStyle: not_to

Capybara/RedundantWithinFind:
  Enabled: true

Capybara/SpecificActions:
  Enabled: true

Capybara/SpecificFinders:
  Enabled: true

Capybara/SpecificMatcher:
  Enabled: true

Capybara/RSpec/HaveSelector:
  Enabled: false

Capybara/RSpec/PredicateMatcher:
  Enabled: true

FactoryBot

FactoryBot/AssociationStyle:
  Enabled: true

FactoryBot/ConsistentParenthesesStyle:
  Enabled: true

FactoryBot/ExcessiveCreateList:
  Enabled: true # Might be annoying in some projects
  MaxAmount: 10 # Could be adapted

# This does not work with transient attributes, too many false positives.
# See also: https://github.com/rubocop/rubocop-factory_bot/issues/73
FactoryBot/FactoryAssociationWithStrategy:
  Enabled: false

FactoryBot/FactoryNameStyle:
  Enabled: true

FactoryBot/IdSequence:
  Enabled: true

FactoryBot/RedundantFactoryOption:
  Enabled: true

FactoryBot/SyntaxMethods:
  Enabled: true

Since these cops are all pending in the main repository, we do not need to discuss about them now. But I will share them as a starting point for future discussions.

tecden commented 5 months ago

Thank you for preparing this change.