arXiv:2609.07482cs.SESep 2026

Manuscript Offprint

arXiv:2609.07482

An Empirical Study on the Impact of Change Granularity in Refactoring Detection

Lei Chen, Shinpei Hayashi

Abstract

Detecting refactorings in commit history is essential to improve comprehension to code changes on code reviews, and to provide valuable information for empirical studies on software evolution. Techniques have been proposed to accurately detect refactorings on the granularity of a single commit. However, refactorings can be made over multiple commits because of their complexity or other practical development problems, which cause detecting on only the granularity of a single commit not enough. We observe that some refactorings can only be detected in coarser granularity, i.e., changes conducted over multiple commits, or in the granularity of a single commit but not in coarse-grained. We call these types of refactorings as coarse-grained refactorings (CGRs) and ephemeral refactorings (EPRs). We investigated the features and causes of CGRs and EPRs through an empirical study of 32 open-source Java projects and found that both commonly occur during development. In addition, we found that refactoring types related to splitting or merging classes and packages, as well as those involving modifications to the inheritance structure, tend to be CGRs, and types targeting small objects such as variables and attributes, and refactorings with context-sensitive detection criteria tend to be EPRs. The causes of CGRs and EPRs are analyzed and categorized, and the relationships between the commit messages of CGRs and themselves are also assessed. We found that about 20% of commit messages explicitly suggest the existence of CGRs. We suggest that CGRs and EPRs be valued in refactoring research and that detectors be extended to identify CGRs.

Keywords: software evolution, refactoring, refactoring detection, commit message

1. Introduction

Refactoring mining within the commit history benefits both software developers and researchers. Refactoring is the process of improving the internal structure of code without changing its external behavior [1]. For developers, it facilitates the understanding of code changes [2] and enhance the effectiveness of code reviews [3]. In terms of researchers, it can provide valuable information for empirical studies on software evolution, such as the benefits of refactorings [4], the relationship between bugs and refactorings [5].

To mine refactorings, recent studies proposed refactoring detectors that detect refactorings by comparing two source code snapshots [2, 6, 7, 8, 9, 10, 11, 12]. While traditional approaches focus on detecting refactorings between releases [6, 7, 8, 9], modern detectors such as RefDiff [10, 11] and RefactoringMiner [2, 12] analyze individual commits, which means that two snapshots before and after a single commit are compared. These methods have achieved high accuracy in detecting refactoring within commits [13].

However, refactorings may be performed over multiple commits. For example, when moving a method from one class to another, some developers choose to first copy the implementation of the method to the target-of-move class in the first commit. After confirming that users will not be affected, the original implementation is removed in the next commit. In this case, the Move Method refactoring could not be detected from either of the two commits using commit-level refactoring detectors, but it becomes detectable from a coarse-grained granularity that spans across both commits.

By investigating the impact of changing the refactoring detection granularity from a single commit to coarser-grained, we are able to gain a deeper insight into the refactorings similar to the above. We define a refactoring whose code changes are recorded across multiple commits, rather than confined in a single commit as coarse-grained refactoring (CGR). Conversely, a refactoring whose code changes are recorded within a single commit and where modifications in adjacent commits would disrupt their integrity are referred to as ephemeral refactoring (EPR). We use the term ephemeral to emphasize its brief lifespan, as these refactorings are confined to a narrow historical scope of commits and will disappear in a broader scope. An example of EPR is that a refactoring is initially applied and then reverted due to being considered an inappropriate change.

The existence of CGRs and EPRs suggests that relying solely on a single specific detection granularity is not enough, as CGRs may be overlooked, and EPRs may require analysis across multiple commits to be detected. This limitation may lead to incomplete or incorrect conclusions in empirical studies, such as refactoring type and software evolution analysis.

Also, uncovering those refactorings can help developers gain a better understanding of code evolution. To investigate the features and causes of CGRs and EPRs, we conduct an empirical study on open-source Java repositories.

We regard the original commits recorded in the commit history as fine-grained and name them fine-grained commits (FGCs). To change the granularity of commits, multiple FGCs are squashed into one to form a coarse-grained com-

Preprint submitted to Journal of Systems and Software mit (CGC). In this way, the code changes from multiple FGCs are combined into a CGC. The number of FGCs squashed into one CGC is referred to as granularity level. Refactoring detection is conducted on both FGCs and CGCs using the state-of-the-art tool RefactoringMiner [2, 12] to extract CGRs and EPRs for analysis.

The main contributions of this paper are shown below:

  • We defined the concept of CGR and EPR and proposed a technique to detect them from the commit history.

  • An empirical study is conducted on a dataset of 32 open-source Java repositories.

  • The features and causes of CGRs and EPRs are analyzed.

  • We investigated the relationship between developers' intentions deduced from commit messages and CGRs. We discussed the implications of CGRs and EPRs for researchers and practitioners.

The findings of this paper are as follows:

  • CGRs and EPRs are common in development, and on average, per 100 refactorings conducted, there are also 5.71 CGRs and 9.89 EPRs be performed.

  • Refactoring types related to splitting or merging classes and packages, as well as those involving modifications to the inheritance structure, tend to be CGRs while types related to operations on small objects such as variables, attributes, and parameters tend to be associated with EPRs.

  • The cause of CGR can be categorized into two types: Generation and Combination according to their composition. While the cause of EPR can be divided as Disruption, Absorption, and Covered.

  • We found that 20% commit messages explicitly express the existence of CGRs, and the characteristics of those commit messages are summarized and categorized into four types.

This paper is an extension of work reported originally in the proceedings of the 30th IEEE/ACM International Conference on Program Comprehension [14]. The main improvements are the following:

  • A more delicate matching scheme is designed to mine more previously undiscovered CGRs.

  • Proposed the definition of EPRs and also the technique to mine them.

  • Conducted an experiment on a larger-scale dataset that contains 32 open-source Java repositories.

  • Analyzed the features from more aspects for CGRs and the features for EPRs.

  • Investigate the causes of EPRs.

  • Implications for both researchers and practitioners.

The remainder of this paper is organized as follows. Section 2 explains the definition of CGR and EPR. Section 3 introduces the background of this study. In Section 4, we explain the matching mechanism of refactorings at different granularities that we designed. Section 5 introduces the overview of our study. We extract CGRs and EPRs on the dataset and analyze and discuss five research questions in Section 6. The possible threats to validity are discussed in Section 7, and the implications are discussed in Section 8. Finally, we conclude our work and state our plans for future work in Section 9.

References (36)