Identifying Refactorable Micro-Clones through Mining Similarity Preserving Change Patterns

Mahbub E Elahi, Manishankar Mondal, Amit Kumar Mondal · 2024

The daily lives of mass amount of people are disrupted by recurring anomalies of software services (such as crashes, denial of services, and security hacks). These anomalies originate from a lack of quality in the software codebase such as code smells. Duplicate codes (code clones), a special type of code smells are problematic and decrease software quality and increase the mentioned anomalies. Existing studies suggest to manage code clones through refactoring in order to minimize clone related complexities. While regular code clones, clones of at least 5 LOC (lines of clone), have been investigated a lot for refactoring, micro-clones (clones of at most 4 LOC) have been ignored in the existing studies. However, a software system generally contains a large number of micro-clones. Aggressively refactoring all these micro-clones is impractical. Thus, it is necessary to identify which of these large number of micro-clones residing in a software system’s codebase should be considered important for refactoring. Our research in this paper investigates this matter.We have investigated a particular clone change pattern, the Similarity Preserving Change Pattern (SPCP), by analyzing the evolutionary history of the micro-clones. We use Nicad and SPCP-Miner for our investigation and obtain the SPCP micro-clone pairs of Type 1, 2, and 3. We manually analyze the SPCP micro-clone pairs and discovered that pairs with LOC 3 and 4 are more refactorable than those with LOC of 1, and 2. Refactorable micro-clones primarily consist of four types of code constructs (functional, conditional, try-catch, and while loop). Additionally, Type 3 micro-clones in Java systems are generally not suitable for refactoring. We developed a webpage page to show micro-clones of 3 types and their refactoring techniques if they are refactorable. On the basis of our findings, we built a tool that can identify refactorable micro-clones from a software system. Our tool is available online.

Read the paper · More papers on PaperTik