
The StoneDetector system is an analysis system for finding code clones in Java programs using control flow information. In contrast to well-known clone detectors, the StoneDetector system uses a special kind of control flow representation for code analysis, i.e., dominator trees. In previous work, the StoneDetector system has been shown to achieve better results for clone detection when compared to other text-based techniques, especially in case of structural code clones and subclones, as well as for code clones with larger syntactic variance. In this paper, after a brief introduction of the basic clone detection technique underlying the StoneDetector system, we present its architecture and its various operation modes working on Java source code and Bytecode.
Semantic and Cross-language code clone generation may be useful for code reuse, code comprehension, refactoring and benchmarking. OpenAI's GPT model has potential in such clone generation as GPT is used for text generation. When developers copy/paste codes from Stack Overflow (SO) or within a system, there might be inconsistent changes leading to unexpected behaviours. Similarly, if someone possesses a code snippet in a particular programming language but seeks equivalent functionality in a different language, a semantic cross-language code clone generation approach could provide valuable assistance. In this study, using SemanticCloneBench as a vehicle, we evaluated how well the GPT-3 model could help generate semantic and cross-language clone variants for a given fragment.We have comprised a diverse set of code fragments and assessed GPT-3s performance in generating code variants.Through extensive experimentation and analysis, where 9 judges spent 158 hours to validate, we investigate the model's ability to produce accurate and semantically correct variants. Our findings shed light on GPT-3's strengths in code generation, offering insights into the potential applications and challenges of using advanced language models in software development. Our quantitative analysis yields compelling results. In the realm of semantic clones, GPT-3 attains an impressive accuracy of 62.14% and 0.55 BLEU score, achieved through few-shot prompt engineering. Furthermore, the model shines in transcending linguistic confines, boasting an exceptional 91.25% accuracy in generating cross-language clones
We introduce TransClone, a language-agnostic clone detection tool that leverages a source-to-source translator and an extended version of the graph matching network to detect clones. This tool accepts a source directory or directories as input and identifies code clones within it. It comes with a command line interface and reports identified clones in a CSV file format. Currently, it supports code written in Java and Python. However, TransClone's modular structure provides a flexible way to augment clone-detection support for multiple languages, as better code translators become available. Our experiment on the benchmark dataset shows that it can detect clones with high precision and recall. The TransClone tool including the datasets and trained model can be found here(1).
Large-scale source-code clone detection is a challenging task. In our previous work, we proposed an approach (SSCD) that leverages artificial neural networks and approximates nearest neighbour search to effectively and efficiently locate clones in large-scale bodies of code, in a time-efficient manner. However, our literature review suggests that the relative efficacy of differing neural network models has not been assessed in the context of large-scale clone detection approaches. In this work, we aim to assess several such models individually, in terms of their potential to maximize recall, while preserving a high level of precision during clone detection. We investigate if ensemble inference (in this case, using the results of more than one of these neural network models in combination) can further assist in this task. To assess this, we employed four state-of-the-art neural network models and evaluated them individually/in combination. The results, on an illustrative dataset of approximately 500K lines of C/C++ code, suggest that ensemble inference outperforms individual models in all trialled cases, when recall is concerned. Of individual models, the ADA model (belonging to the ChatGPT family of models) has the best performance. However commercial companies may not be prepared to hand their proprietary source code over to the cloud, as required by that approach. Consequently, they may be more interested in an ensemble-combination of CodeBERT-based and CodeT5 models, resulting in similar (if slightly lesser) recall and precision results.
Many studies have been conducted to identify various types of code clones with a focus on accuracy, scalability, and performance. However, there has been limited exploration into the nature of code clones. Even fundamental questions, such as whether authors who write many non-clone lines also tend to write many clone lines, or whether code snippets in the same clone set were written by the same author or different authors, have not been thoroughly investigated. In this paper, we explore such fundamental questions regarding code clone authorship. We analyzed Java files from 153 Apache projects on GitHub, with a focus on line-level granularity. The analysis results showed that for 150 out of the 153 projects, the numbers of non-clone lines and clone lines contributed by each author are linearly correlated. We also found that two-thirds of the clone sets in all projects are primarily contributed to by single leading authors. These results confirm our intuitive understanding of clone characteristics, even though no previous publications have provided empirical validation data from multiple projects. Since these results could assist in designing better clone management methods, we will explore the implications of developing an effective clone management tool.