Lightweight Detection of Duplicated Code. A Language-Independent Approach

Sté́phane Ducasse, Oscar Nierstrasz, Rieger, Matthias · Bern Open Repository and Information System (University of Bern)

Duplicated code can have a severe, negative impact on the maintainability of large software systems. Techniques for detecting duplicated code exist but they rely mostly on parsers, technology that is often fragile in the face of different languages and dialects. In this paper we show that a lightweight approach based on simple string-matching can be effectively used to detect a significant amount of code duplication. The approach scales well, and can be easily adapted to different languages and contexts. We validate our approach by applying it to a number of industrial and open source case studies, involving five different implementation languages and ranging from 256KB to 13MB of source code. Finally, we compare our approach to a more sophisticated one employing parameterized matching, and demonstrate that little if anything is gained by adopting a more heavyweight approach.

Read the paper · More papers on PaperTik