Graph-based duplicated code detection with RefactorErl
István Bozó, Zsófia Erdei, Melinda Tóth · Annales Universitatis Scientiarum Budapestinensis de Rolando Eötvös Nominatae Sectio computatorica · 2024
Code duplicates are created for various reasons such as code reuse by copying existing fragments of code (copy-and-paste programming). Considering the huge amount of duplicated code and its maintenance cost in large software systems, it is crucial to detect code clones. In this paper we give a graph-based algorithm which uses the semantic program graph generated by the tool RefactorErl, a source code comprehension and refactoring tool for the programming language Erlang, to find different types of code clones in the source code. The presented algorithm was able to efficiently detect not only textually identical code fragments (Type I) but also copied and slightly modified code fragments, such as changed, added or removed expressions, in addition to variations in identifiers, literals, types, whitespace characters, layout and comments (Type II, Type III).