Without examining each method, how can I find duplicate methods in a class? Duplicate methods are defined as the same code within the method body and, likely but not guaranteed, the same method signature.
I’m cleaning up, re-designing, and refactoring some projects. One thought I have is to copy all the utility methods into one class, find the duplicates, delete them, and move on to the next task. I’d rather not look at each method individually to find duplicates.
Edit 1: Just to be clear, the duplicate methods are identical code. The result of copying & pasting. This is not about finding duplicated functionality, i.e., a method with a different name and different method structure varibale names.
There are tools that try to automatically find duplicated code (within the same class, or across an entire project), while allowing for minor edits (e.g., variable renames, changing constants, etc.) that don’t affect the overall behaviour of the method.
A short list can be found at Duplicate code (Wikipedia).