Conversation
| It's a combination of the [official `rails-friendly` configuration recommended in the Reek's README](https://github.com/troessner/reek?tab=readme-ov-file#working-with-rails) and some changes to the default rules. | ||
|
|
||
| ```yml | ||
| detectors: |
There was a problem hiding this comment.
I think this is useful too.
It allows us to do rescue e => and map { |x| x.do_something }
UncommunicativeVariableName:
accept:
- e
- x
There was a problem hiding this comment.
I wonder if we should also add _ for those times we have a unused variable?
There was a problem hiding this comment.
added these 3 accepted short names
There was a problem hiding this comment.
I wonder if we should add k and v as they are common short names for key and value when iterating over a hash
There was a problem hiding this comment.
I updated this to include k and v
| TooManyStatements: | ||
| max_statements: 10 # original is 5 | ||
| DuplicateMethodCall: | ||
| max_calls: 3 # original is 1 |
There was a problem hiding this comment.
Maybe I am wrong, but from what I remember the duplicate method calls happen often in tests when you are calling a method several times??
There was a problem hiding this comment.
I just tried calling a method multiple times in a single test and reek doesn't complain about it
I'm not sure how it works internally but it seems it won't complain during tests? we can always change this later to disable it for the test and spec directories I guess if it starts creating issues (maybe there's some edge case I don't know how to trigger)
| UnusedPrivateMethod: | ||
| enabled: false |
There was a problem hiding this comment.
I'm wondering if it wouldn't be better to have it be true. Even in controllers and models, if it's unused, wouldn't we want to remove them?
There was a problem hiding this comment.
the problem with this rule is that (at least from my tests), it's not smart enough to detect that you are referencing a private method in a callback, as in before_action :some_private_method on a controller or an after_save :do_something_private in a model
we have that enabled above in general, but we are disabling them for controllers and models
There was a problem hiding this comment.
it was showing many false positives saying a private method was not used when it was used in a callback
| It's a combination of the [official `rails-friendly` configuration recommended in the Reek's README](https://github.com/troessner/reek?tab=readme-ov-file#working-with-rails) and some changes to the default rules. | ||
|
|
||
| ```yml | ||
| detectors: |
There was a problem hiding this comment.
I wonder if we should also add _ for those times we have a unused variable?
| public_methods_only: true # original is false | ||
|
|
||
| directories: # reek's recommendation for Rails applications unless a comment is added | ||
| "app/controllers": |
There was a problem hiding this comment.
In the past I have found the following helpful in controllers too:
FeatureEnvy:
enabled: false
TooManyMethods:
enabled: false
TooManyStatements:
enabled: false
FeatureEnvy: It is easy for controller methods to interact with other parts of the application
TooManyMethods: Controllers can easily go over 15 methods
TooManyStatements: Controllers methods easily go over 5 lines
There was a problem hiding this comment.
do you think those are better fully disabled or maybe add as exceptions when needed?
I'm running reek on fastruby with the current state of this proposed config and I don't get any TooManyMethods nor FeatureEnvy warnings for controllers, and only 2 TooManyStatements in one of the controllers (maybe those actions can be ignored as exceptions or refactored)
There was a problem hiding this comment.
maybe we can disable TooManyMethods for controllers and models too? I don't think it adds that much value (I think we are already good at not putting methods where they don't belong, and when they are in the right place it would be annoying to have reek complain just because of the number)
There was a problem hiding this comment.
I am onboard with disabling TooManyMethods in controllers/models yes.
And perhaps you are right, we can disable feature envy and too many statements where needed.
There was a problem hiding this comment.
I added the change to ignore TooManyMethods for models and controllers
JuanVqz
left a comment
There was a problem hiding this comment.
Looks good to me as initial RFC ![]()
| NilCheck: | ||
| enabled: false # in some projects were this was enabled, it was a false positive being ignored | ||
| TooManyStatements: | ||
| max_statements: 10 # original is 5 |
There was a problem hiding this comment.
I think for some of the client projects, we might be easily breaking this rule as we do not have any control on the state at which we start working on the project.
There was a problem hiding this comment.
I see that TooManyStatements is set to false for controllers and models. I think that do cover some of my concern. Although I have seen clients putting more than 10 lines of code in methods that are placed under lib, config.
There was a problem hiding this comment.
this will not be used on client projects, only for internal projects and only for FastRuby.io, Ombulabs.com, and Points for now
|
I think we can add these as well to the starting point: Long Parameter List (https://github.com/troessner/reek/blob/master/docs/Long-Parameter-List.md) - This encourages better design. TooManyInstanceVariables - Right now, we have set it to false. Although I think we should set it to true with may be a higher number of variables allowed. It signals that classes doing too much. Data Clump (https://github.com/troessner/reek/blob/master/docs/Data-Clump.md) - It also encourages the idea of using objects and cleaner design. |
LongParameterList and DataClump are enabled by default already, and we are not disabling them for TooManyInstanceVariables, this is also enabled by default, we are disabling it only for controllers because we usually set many instance variables to pass data to the views |
|
👍 |
julioalucero
left a comment
There was a problem hiding this comment.
It is nice to have this new configuration as a starting point!
Read the .md file included in the DIFF for details.
You can see the parsed version of the file at https://github.com/fastruby/RFCs/blob/DT-462-shared-default-reek-configuration/2025-06-02-default-reek-configuration.md