-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Private methods in subclasses incorrectly flagged as "never being called" #842
Comments
This is one of this detectors know limitations we can't fix. At least not without implementing a global class / method registry. So for now I'm afraid you'll have to disable this detector either via source code comment or disable it completely in your config. Using We're thinking of disabling this detector by default in #844 - let's continue the discussion over there. |
I would say this is exactly the scenario this detector warns against: Using private methods to provide plug-in functionality, so this particular issue is not due to Reek's (very real) limitation to single files. The fact that it flags each container class/module as well is a bug. I'll open a separate ticket for that. |
But there are a lot of use cases where just defining a private method in the parent class and use it in its children has nothing to do with plug-in behaviour but rather is just good OOP style. |
The issue is with defining a private method in the parent class and only using it in its children. It sounds attractive at first, like a kind of 'toolbox', but in my experience it leads to an unmanageable mess very quickly. By the way, the OP's case is the reverse: The method is defined in the child class to fill in a template method. I'm a bit less convinced this is a problem, although I would tend to use a collaborator object to provide the steps needed in the template. |
Good point, I had missed this detail, thanks for the correction. |
I've seen PR #794 (and #724) and the issues they mention, and all the code I see seems to assume that the code being examined is either in a top-level class or module. Also, several releases have been tagged since #794 was merged into 3.8.0; this may be a regression.
I've written this up extensively in a Gist (with short code files attached) whose opening comment starts out as:
Thanks in advance for any attention this gets.
The text was updated successfully, but these errors were encountered: