I am managing a group of three interns working on a php project. They seem to be not good at refactoring and are using duplicate code in multiple places. I am looking for a tool which I can use to find this duplicate code so I can show them.
This would make my job easier, and the project more elegant and less prone to errors. Any leads?
Duplicate code can be hard to find, especially in a large project. But PMD's Copy/Paste Detector (CPD) can find it for you! CPD works with Java, JSP, C/C++, C#, Go, Kotlin, Ruby, Swift and many more languages. It can be used via command-line, or via an Ant task.
If the duplicate code is inside a constructor, use Pull Up Constructor Body. If the duplicate code is similar but not completely identical, use Form Template Method. If two methods do the same thing but use different algorithms, select the best algorithm and apply Substitute Algorithm.
PMD is a good tool to find code duplication. Here is a link to the site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With