Add and apply Rails/FindByOrAssignmentMemoization rule

This rule was added in rubocop-rails 2.33.

At first, I wasn't very fond of this rule. It made the code less
readable even if it improved performace in some cases.

Then I realized that in the `Admin::MachineLearning::SettingComponent`
we were using `find_by` when we should be using `find_by!` instead, and
we detected that thanks to this rule.

So, only for that reason, I'm adding this rule, but I'm fine if we
remove it.
This commit is contained in:
Javi Martín
2025-10-31 13:10:20 +01:00
parent 048bdb2e9e
commit 0ca94e5443
4 changed files with 10 additions and 3 deletions

View File

@@ -441,6 +441,9 @@ Rails/FindBy:
Exclude:
- "config/initializers/ahoy.rb"
Rails/FindByOrAssignmentMemoization:
Enabled: true
Rails/FindEach:
Enabled: true