Clone Notifier: Developing and Improving the
System to Notify Changes of Code Clones
Shogo Tokui∗ , Norihiro Yoshida† , Eunjong Choi‡ , and Katsuro Inoue∗∗ Osaka University, Japan, {s-tokui, inoue}@ist.osaka-u.ac.jp† Nagoya University, Japan, yoshida@ertl.jp‡ Kyoto Institute of Technology, Japan, echoi@kit.ac.jp

Abstract—A code clone is a code fragment that is identical orsimilar to it in the source code. It has been identified as one of themain problems in software maintenance. When a developer fixes
a defect, they need to find the code clones corresponding to thecode fragments. In this paper, we present Clone Notifier, a systemthat alerts on creations and changes of code clones to softwaredevelopers. First, Clone Notifier identifies creations and changesof code clones. Subsequently, it groups them into four categories(new, deleted, changed, stable) and assigns labels (e.g., consistent,
inconsistent) to them. Finally, it notifies on creations and changesof code clones along with the corresponding categories and labels.
Clone Notifier and its video are available at: https://github.com/
s-tokui/CloneNotifier.
Index Terms—code clone, tracking clone, software maintenanceCheck
the results

CommitHTML
files
Developer

Current
source code
VCS
Previous
sourcecode
STEP1
Detectingclone sets

Previous
clone set list

STEP 1Resultsummary

Detectingclone sets

Detailresults

Current
clone set list
STEP 2
Tracking&
Categorizing
clone sets

Categorized
clone set list

STEP 3
Notifyingdevelopers&
Generating
result files

Fig. 1. An overview of Clone Notifier

I. I NTRODUCTION
A code clone is a code fragment that is identical or similar
to it in the source code. It has been identified as one of themain problems in software maintenance [1]. When a developer
fixes a defect, they have to find the code clones corresponding
to the code fragment.
Simultaneous modification is needed in maintenance forclone sets (i.e., sets of code clones in which all pairs of thecode clones are identical or like each other) [2]. However,consistent modification of all code clones is an error-pronetask. Therefore, tool-based management is required for simultaneous modification of code clones.
Our research team has developed a Clone Notifier, whichenables consistent modification of code clones by automatically alerting developers of changes in the information ofcode clones [3]. Clone Notifier detects code clones using
a token-based code clone detector named CCFinderX [4].
Furthermore, it provides the change information (i.e., changed,
deleted, new, and stable) of clone sets based on the changes
between two revisions. Clone Notifier continuously detects
the change information of code clones and sends an e-mailabout the change to the developers.
However, it is difficult for developers to maintain many code
clones suggested by Clone Notifier consistently. Specifically,
there are many inconsistent changes to code clones, and someof them contain bugs [5], [6], [7]. To mitigate this problem,
we improved the Clone Notifier in the following four ways
to show developers the areas where they should focus (e.g.,inconsistent changes).

978-1-7281-5143-4/20/$31.00 c 2020 IEEEClassification of changed clone sets into refined categories• Addition of two code clone detectors SourcererCC [8]and CCVolti [9]• Change of the definition of a clone set• Improving the method of tracking of code clones [10]These improvements make it possible to notify developers ofinconsistent changes.
In this paper, we demonstrate how Clone Notifier supports
developers, such that they can fix defects in clone sets consistently. In this paper, we illustrate the use of Clone Notifier
using open source software PostgreSQL1 from 23rd June 2018
to 22nd June 2019.
•

II. C LONE N OTIFIER : OVERVIEW
Clone Notifier is a system used to generate HTML files
with the change information of code clones from the sourcecode of two revisions as shown in Figure 1. Moreover, Clone
Notifier notifies developers of the summary of the change
information. It performs three steps: 1) detecting the clone
sets in each revision, 2) tracking and categorizing clone sets
between two revisions, and 3) notifying developers of thechange information of code clones.
A. Detect Code Clones
Clone Notifier defines a clone set as a set of code clones
in which all pairs of code clones are identical or similar to642

1 https://github.com/postgres/postgres

SANER 2020, London, ON, Canada
Tool Demonstrations

TABLE I
CATEGORIES OF CLONE SETS

Stable clone setsthat were not changed.

Deleted clone setsthat existed in the previous
version and removed.

New clone setsthat did not exist
in the previous version
but the current version.
Changed clone setsthat include edited, added,
or deleted code clones.

TABLE II
L ABELS OF CHANGED CLONE SETS
Label
Add
Subtract
Shift
Consistent
Inconsistent

Definition
An added code clone exists.
A deleted code clone exists.
A code clone which is moved
from another clone sets exists.
All code clones were done same edit.
At the same time, an edited code
clone and a stable code clone exist.

each other. Code clone detectors output clone pairs (pairs ofcode clones) from each revision of source code. Clone Notifierdetects the clone pairs in the source code using the three code
clone detectors SourcererCC [8], CCFinderX [4] and CCVolti[9]. The supported languages of Clone Notifier depend on thecode clone detectors.
After detecting the clone pairs, Clone Notifier constructs
clone sets from the clone pairs. When the syntax code clone
detector (e.g., CCFinderX), detects two clone pairs (c1 , c2 ) and(c2 , c3 ), the clone c1 is exactly similar to the clone c3 because
the relationship preserves the transitive property. When thenear-miss code clone detector (e.g. SourcererCC and CCVolti),
detects two clone pairs (c1 , c2 ) and (c2 , c3 ), clone c1 may bedifferent from clone c3 .
When developers use the near-miss code clone detector,
Clone Notifier constructs clone sets from clone pairs of
JGraphT2 for solving the maximal clique problem. A clique
is a subset of vertices of an undirected graph, such that edges
exist between two different vertices in the clique. A maximal
clique is a clique that does not exist exclusively within thevertex set of a larger clique. For example, there are four codefragments c1 , c2 , c3 , c4 . When detecting the four clone pairs(c1 , c2 ), (c2 , c3 ), (c3 , c1 ) and (c3 , c4 ), Clone Notifier detects(c1 , c2 , c3 ) and (c3 , c4 ) as the clone sets. As clone sets are
maximal cliques of JGraphT, clone sets can be included incode clones that may need simultaneous modification without
a surplus or deficiency.
B. Track and Categorize Clone Sets
After detecting clone sets, Clone Notifier tracks from theclone sets in the old revision to the clone sets in the newrevision with the position of the code fragments in each sourcecode. To track code clones between two revisions, Clone
Notifier calculates the overlapping location of code clones,
2 https://jgrapht.org/

Fig. 2. Configuration GUI

based on the location overlapping function of Kim et al. [10].
Location overlapping measures how much two locations l1 andl2 overlap each other (0 ≤ LO(l1, l2) ≤ 1). Clone Notifier
uses the difference between files of the same name in eachrevision, without the added and deleted lines. It computes therelative proportion of an overlapped region between l1 and thecalibrated l2.
LO(l1, l2) =min(ne , oe ) − max(ns , os )ne − ns(1)

where l1 in the old revision spans from the line os to the line
oe , and the calibrated location of l2 in the new revision spansfrom the line ns to the line ne . If the location overlapping
between the two code clones is 70% or more, Clone Notifier
tracks from the code clone at the old revision to the code
clone at the new revision. If a code clone exists only ineither revision, it is defined as a deleted/added code clone
or is included as a subtract/add clone set, as shown in Table
II. The condition to track a clone set in the new revision isthat the clone set must contain the largest number of code
clones tracked from the code clones of the clone set in the oldrevision.
After tracking the clone sets, Clone Notifier classifies theclone sets into four categories (stable, changed, new, anddeleted) as shown in Table I [3]. According to the type ofediting of the code clones included in the changed clone
set, Clone Notifier gives the changed clone sets any of fivelabels as shown in Table II. The labels are add, subtract, shift,643

code pages are written based on the difference between two
revisions, and developers can easily check how the code clonechanged.
III. I LLUSTRATIVE U SAGE S CENARIO
In this section, we demonstrate a usage instance of Clone
Notifier to detect the inconsistent change clone sets. Moreover,
we examine the results to uncover the code clone which should
be fixed.
A. Usage Scenario

Fig. 3. Home pageFig. 4. Clone set informationconsistent, and inconsistent [10]. Clone Notifier can notify thedevelopers of the clone set information in more detail.
C. Notify Developers and Show the Change Information
After categorizing the clone sets, Clone Notifier outputs
the result file about the change information of the clone sets
and sends an e-mail to developers. The extension of the result
file is HTML. If developers set up their e-mail information,
they can receive an e-mail consistently with a summary of theresults and a link to the result file. The e-mail messages are asummary of the results, which have four pieces of information:
number of clone sets, number of code clones, number offiles containing code clones, and a link to the home page forthe result in a browser. Developers can analyze the change
information of the code clones.
Figure 3 shows the home page of the result files in abrowser. Developers click the ‘Changed clone set’ and checkthe clone setlist page to examine the details of the changed
clone sets. In Figure 4, the clone setlist page shows the details
information of the clone sets. The several pieces of information
are the labels, categories of the code clones shown in section
II-B, file containing the code clone, and line number of thecode clone in the new revision. Notably, the clone sets are
sorted by the same label, and the inconsistent changes in theclone sets are at the top of the list. Developers click the IDof the code clone 0.0 on the clone setlist page and check thesource code page. As shown in Figures 5, 6 and 7, the sourceFirst, the developer sets the configurations of the Clone
Notifier. After downloading Clone Notifier, the developer
executes setting.jar and write (e.g., the code clone detection
tool, two versions of the directory path, email address, andconfiguration file name) to generate the configuration file. Figure 2 shows the input form of the configuration settings. Next,
the developer executes Clone Notifier with the configuration
file as an argument. Finally, after completing the execution,
the developer receives an email from Clone Notifier with asummary of the results. In this use case, one inconsistentchanged clone set has been detected. To investigate whether
any defect exists in the code clone, the developer accesses the
URL written in the email and checks the results.
When accessing the URL, the home page is displayed, as
first shown in Figure 3. If the developer clicks a clone set
category name, he can check the detailed information aboutthat category. On the Clone Set page, as shown in Figure 4,
the developer can confirm the change information of the code
clone for each clone set. The information includes whether
the code clone has been modified, is containing a file, and theline location in the source code. When the developer clicks
the code clone ID, he can see more detailed information aboutchanges. In the source code page, as shown in Figures 5, 6, and7, the code clone in the source code is displayed. If changes
have been made, the changes are colored.
B. Findings
In this section, we illustrate three instances of inconsistentchanges detected by the Clone Notifier.
The first instance of inconsistent change on 29th Dec 2018is the clone set of three code fragments, as shown in Figure
5. These code fragments are in the same file. Although, it
was necessary to refactor the other two same code clones, themodified one was refactored. The commit message includes
that the modified coding is too convoluted and hard to follow.
Approximately two weeks before this commit, the committer
discussed with PostgreSQL developers and improved the readability of this code by e-mail3 . When a code clone in a clone
set was very convoluted, the other code clones are considered
to be convoluted. Thus, they should be identified as refactoring
candidates.
The second inconsistent change on 5th Apr 2019 is the clone
set of three code fragments, as shown in Figure 6. These code
3 https://www.postgresql.org/message-id/20181206222221.
g5witbsklvqthjll@alvherre.pgsql

644

Stable Code Clone

Modified Code Clone

File: src/backend/executor/execMain.c

File: src/backend/executor/execMain.c

Fig. 5. Inconsistent change (previoius commit ID: f7ea1a4233, current commit ID: e8b0e6b82d)

Stable Code Clone

Modified Code Clone

File: src/backend/utils/cache/lsyscache.c

File: src/backend/utils/cache/lsyscache.c

Fig. 6. Inconsistent change (previoius commit ID: 82150a05be, current commit ID: edda32ee25)

fragments are in the same file. Although, it was necessary
to refactor the other two same code clones, the modified
one of these code fragments was refactored, such that thecondition statement changes to the condition negative form.
The commit message indicates that “the developer rewrites
get attgenerated() to avoid compiler warning if the compiler
does not recognize that error log does not return”. Therefore,
to avoid the compiler warning with the other code clones in theclone set, these code clones should be modified with the samechange. If Clone Notifier is constantly used, the developer canconsistently refactor.
The third inconsistent change on 17th Apr 2019 is theclone set of two code fragments, as shown in Figure 7.
These code fragments are in the same file. One of these codefragments was refactored, such that it added a NULL return if
DataChecksumsEnabled is false. Although, it was necessary torefactor the other code clone in the same way as the refactoredcode fragment. The commit message includes that ‘returning
0 could falsely indicate that there is no problem, but returning
NULL correctly indicates that there is no information about
potential problems’.
IV. R ELATED W ORK
Our research team has developed CCEvovis [11], which
is a system that visualizes the evolution of code clones [3].
It highlights and visualizes the clone change for developers
to understand. Saha et al. described the design and implementation of a near-miss clone genealogy extractor, gCad645

Stable Code Clone

Modified Code Clone

File: src/backend/utils/adt/pgstatfuncs.c

File: src/backend/utils/adt/pgstatfuncs.c

Fig. 7. Inconsistent change (previoius commit ID: 9010156445, current commit ID: 252b707bc4)[12], which can extract and classify both exact and nearmiss clone genealogies. In this paper, we described the Clone
Notifier that constantly notifies about the inconsistent changes,
including the changes in the information of the code clones.
Other studies have existed on detection code clones [13],[14], [15], and code clones evolution [16], [17], [18]. Also,
Mondai et al. have found that the percentage of severe bugs issignificantly higher in micro-clones than regular clones [19],[20].
V. S UMMARY
In this paper, we presented a Clone Notifier that automatically alerts about changes in the information of code
clones. We demonstrated the use of Clone Notifier to detectsuch changes. We found using improved Clone Notifier that
there were code clones that did not change consistently in thechanged clone set. And, we have future work to implement
incremental clone detection because the detection tools usedby Clone Notifier detect code clones for each revision, andthis treatment costs a lot for large software projects.
ACKNOWLEDGEMENTS
This work was supported by JSPS KAKENHI Grant Numbers JP18H04094, JP19K20240. We would like to thank
Editage (www.editage.com) for English language editing.
R EFERENCES[1] C. K. Roy, J. R. Cordy, and R. Koschke, “Comparison and evaluationof code clone detection techniques and tools,” Science of Computer
Programming, vol. 74, no. 7, pp. 470–495, 2009.
[2] M. Fowler, Refactoring: improving the design of existing code.
Addison-Wesley Professional, 2018.
[3] Y. Yamanaka, E. Choi, N. Yoshida, K. Inoue, and T. Sano, “Applying
clone change notification system into an industrial development process,”
in Proc. ICPC, 2013, pp. 199–206.
[4] T. Kamiya, S. Kusumoto, and K. Inoue, “CCFinder: a multilinguistic
token-based code clone detection system for large scale source code,”IEEE Transactions on Software Engineering, vol. 18, no. 7, pp. 654–670,
2002.
[5] K. Inoue, Y. Higo, N. Yoshida, E. Choi, S. Kusumoto, K. Kim, W. Park,and E. Lee, “Experience of Finding Inconsistently-Changed Bugs in
Code Clones of Mobile Software,” in Proc. IWSC. IEEE, 2012, pp.
94–95.

[6] L. Jiang, Z. Su, and E. Chiu, “Context-based detection of clone-relatedbugs,” in Proc. ESEC. ACM, 2007, pp. 55–64.
[7] E. Juergens, F. Deissenboeck, B. Hummel, and S. Wagner, “Do CodeClones Matter?” in Proc. ICSE. IEEE, 2009, pp. 485–495.
[8] H. Sajnani, V. Saini, J. Svajlenko, C. K. Roy, and C. V. Lopes,“SourcererCC: Scaling code clone detection to big-code,” in Proc. ICSE,
2016, pp. 1157–1168.
[9] K. Yokoi, E. Choi, N. Yoshida, and K. Inoue, “Investigating vector-based
detection of code clones using bigclonebench,” in Proc. APSEC, 2018,
pp. 699–700.
[10] M. Kim, V. Sazawal, D. Notkin, and G. Murphy, “An empirical studyof code clone genealogies,” in Proc. ESEC/FSE, 2005, pp. 187–195.
[11] H. Honda, S. Tokui, K. Yokoi, E. Choi, N. Yoshida, and K. Inoue,“CCEvovis: A Clone Evolution Visualization System for Software
Maintenance,” in Proc. ICPC, 2019, pp. 122–125.
[12] R. K. Saha, C. K. Roy, and K. A. Schneider, “gCad: A Near-Miss Clone
Genealogy Extractor to Support Clone Evolution Analysis,” in Proc.
ICSM, 2013, pp. 488–491.
[13] F. Farmahinifarahani, V. Saini, D. Yang, H. Sajnani, and C. V. Lopes,“On precision of code clone detection tools,” in 2019 IEEE 26th International Conference on Software Analysis, Evolution and Reengineering(SANER). IEEE, 2019, pp. 84–94.
[14] L. Büch and A. Andrzejak, “Learning-based recursive aggregation of
abstract syntax trees for code clone detection,” in 2019 IEEE 26th International Conference on Software Analysis, Evolution and Reengineering(SANER). IEEE, 2019, pp. 95–104.
[15] C. K. Roy and J. R. Cordy, “Benchmarks for software clone detection:
A ten-year retrospective,” in 2018 IEEE 25th International Conference
on Software Analysis, Evolution and Reengineering (SANER). IEEE,
2018, pp. 26–37.
[16] E. Duala-Ekoko and M. P. Robillard, “Clonetracker: tool support forcode clone management,” in Proceedings of the 30th international
conference on Software engineering. ACM, 2008, pp. 843–846.
[17] G. Zhang, X. Peng, Z. Xing, S. Jiang, H. Wang, and W. Zhao, “Towards
contextual and on-demand code clone management by continuous monitoring,” in 2013 28th IEEE/ACM International Conference on AutomatedSoftware Engineering (ASE). IEEE, 2013, pp. 497–507.
[18] E. Duala-Ekoko and M. P. Robillard, “Clone region descriptors: Representing and tracking duplication in source code,” ACM Transactions on
Software Engineering and Methodology (TOSEM), vol. 20, no. 1, p. 3,
2010.
[19] J. F. Islam, M. Mondal, and C. K. Roy, “A comparative study ofsoftware bugs in micro-clones and regular code clones,” in 2019 IEEE
26th International Conference on Software Analysis, Evolution andReengineering (SANER). IEEE, 2019, pp. 73–83.
[20] M. Mondai, C. K. Roy, and K. A. Schneider, “Micro-clones in evolving
software,” in 2018 IEEE 25th International Conference on Software
Analysis, Evolution and Reengineering (SANER). IEEE, 2018, pp. 50–
60.

646