reek icon indicating copy to clipboard operation
reek copied to clipboard

Do not raise Utilityfunction for methods defined in a class_method block

Open mateusluizfb opened this issue 3 years ago • 7 comments

Addresses https://github.com/troessner/reek/issues/1538

This PR implements a way to not raise UtilityFunction warning for methods defined in class_methods block

mateusluizfb avatar Mar 29 '21 23:03 mateusluizfb

I am kind of hesitant to merge something that is specific to Rails but since it's seemingly used a lot...idk. Wdyt @mvz ?

troessner avatar Apr 01 '21 09:04 troessner

Yes, I'm also wondering how we can support this in a more generic way. Also, I think there's in issue that the proposed solution will suppress UtilityFunction in the whole module instead of just inside the class_method block. I need to look into this a little bit more over the weekend.

mvz avatar Apr 01 '21 10:04 mvz

To generalize this, we could add a configuration option to list which methods introduce a block that defines class methods. The default option would be empty, but users can set it to [:class_methods] if Reek is used in a Rails project.

mvz avatar Apr 02 '21 11:04 mvz

Excellent idea @mvz!

troessner avatar Apr 02 '21 13:04 troessner

@mvz nice idea, is there something in the project that I could reuse or base myself? Like a custom Rails configuration module or a class that does something similar

mateusluizfb avatar Apr 07 '21 23:04 mateusluizfb

@mvz seems like we forgot this one, I can see that you assigned this to yourself, any chance you pick it up again?

troessner avatar Oct 10 '23 12:10 troessner

Feel free to ping me again as well

mateusluizfb avatar Nov 13 '23 21:11 mateusluizfb