Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an automatic tool to find the DRY-ness of your code base?

Tags:

dry

I am a strong advocate of the DRY principle:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

Are there any tools that can test a code base for the amount of DRYness and both quantify and pinpoint specific examples for correction?

like image 406
Scott Stafford Avatar asked Dec 16 '11 22:12

Scott Stafford


People also ask

How can we code in a DRY manner?

DRY — Don't Repeat Yourself. According to this principle, a single piece of information should be present in only one place and in an authoritative manner in your system. To put it in simple terms avoid redundant repeated code.

What is DRY dont repeat yourself?

November 2021) "Don't repeat yourself" (DRY) is a principle of software development aimed at reducing repetition of software patterns, replacing it with abstractions or using data normalization to avoid redundancy.

What does DRY stand for in coding?

The DRY (don't repeat yourself) principle is a best practice in software development that recommends software engineers to do something once, and only once.


1 Answers

PMD's Copy Past Detector (CPD)

Duplicate code can be hard to find, especially in a large project. But PMD's Copy/Paste Detector (CPD) can find it for you!

Note that CPD works with Java, JSP, C, C++, Fortran and PHP code.

You can run it commandline, there is an ANT task, and an Eclipse plugin.

like image 191
Mads Hansen Avatar answered Jun 29 '23 10:06

Mads Hansen