You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pardaloupa
changed the title
Inconsistent reporting for FeatureEnvy when using module_function or private_class_method
Inconsistent reporting for FeatureEnvy when using module_function and/or private_class_method
Jul 13, 2018
I just started looking into this and the problem is that with module_function both a class method and an instance method are created. So, you can still include the Module and will have active_users as a (private) instance method. Hence, it is a valid candidate to check for FeatureEnvy (and UtilityFunction).
Hmmm, to me it seems like this is one of the edge cases where we'll never have a solution that works for everybody. I agree with @mvz that the check is valid. @mvz what do you think about updating our docs for FeatureEnvy with a proper example and reasoning behind our decision?
I've just realised that the situation is even more confusing for modules in general: If you define a module for the purpose using it with Class#extend, Reek will treat the methods as instance methods, even though they will be class methods on the extended class.
The following code
Goes away if I use def self.active_users. (prepend self)
The same exact issue occurs when using module_function.
Reek seems to fail to detect that methods defined using module_function/ private_class_method are class instance methods and not instance methods
This is the same issue as #1337 this merge request is also related #1338
The text was updated successfully, but these errors were encountered: