Download - Visualization of Clone Detection Results
![Page 1: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/1.jpg)
with Jeff Gray and Ira Baxter
Robert Tairas
Software Composition and Modeling Laboratory
Department of Computer and Information SciencesUniversity of Alabama at Birmingham
S o f t C o m
Visualization of Clone Detection Results
Eclipse Technology Exchange Workshop
OOPSLA 2006Portland, Oregon
![Page 2: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/2.jpg)
2
Code Clones
A sequence of statements that are duplicated in multiple locations in a program
_____________________________________________
________________________________________________
_______________________________________________
__________________________________________________________________
_________________________________
________________________
________________
_________________
_______________________________________________________________________________
__________________________________________________
Source Code
__________________________
ClonedCode
![Page 3: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/3.jpg)
3
Clones in Source Code
Copy-and-paste parts of code from one location to another The copied code already
works correctly No time to be efficient
Research shows that5-10% of large scalecomputer programsare clones (Baxter, 98)
_____________________________________________
________________________________________________
_______________________________________________
__________________________________________________________________
_________________________________
________________________
________________
_________________
_______________________________________________________________________________
__________________________________________________
Source Code
![Page 4: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/4.jpg)
4
Supporting Tool: CloneDR
Commercial clone detection tool developed by Semantic Designs
Finds clones by examining the abstract syntax tree representation of a program
Java version freely available at:http://www.semanticdesigns.com/Products/Clone/register-download.html
![Page 5: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/5.jpg)
5
Supporting tool: AJDT Visualiser Plugin Part of the AspectJ Development Tools
(AJDT) project AJDT Visualiser website:
http://www.eclipse.org/ajdt/visualiser An extension point to pass information:
Bars:Implement
IContentProvider
Interface
Stripes:Implement IMarkupProvider Interface
Visualiser View
![Page 6: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/6.jpg)
6
Clone Detection Results=== Tree Clone Tuple ====Tuple with 7 clones, 3 parameters; similarity = 0.9873417721518988#4 #10f577d0 #97986c0
Clone 1: 6 lines from Line 43 to 48 File: c:/temp/runtime-EclipseApplication/JHotDraw/src/org/jhotdraw/contrib/WindowMenu.javanew AbstractCommand("Cascade", newEditor) { public void execute() { WindowMenu.this.desktop.cascadeFrames(); }
public boolean isExecutable() { return super.isExecutable() && (WindowMenu.this.desktop.getAllFrames().length > 0); }}
--------------------------------------------------------------------------------#4 #10f577d0 #979d860
Clone 2: 6 lines from Line 51 to 56 File: c:/temp/runtime-EclipseApplication/JHotDraw/src/org/jhotdraw/contrib/WindowMenu.javanew AbstractCommand("Tile", newEditor) { public void execute() { WindowMenu.this.desktop.tileFramesHorizontally(); }
public boolean isExecutable() { return super.isExecutable() && (WindowMenu.this.desktop.getAllFrames().length > 0); }}
--------------------------------------------------------------------------------#4 #10f577d0 #9e77f40
Clone 3: 7 lines from Line 52 to 58 File: c:/temp/runtime-EclipseApplication/JHotDraw/src/org/jhotdraw/contrib/CTXWindowMenu.javanew AbstractCommand("Cascade", newEditor) { public void execute() { CTXWindowMenu.this.desktop.cascadeFrames(); }
public boolean isExecutable() { return super.isExecutable() && (CTXWindowMenu.this.desktop.getAllFrames().length > 0); }} …
![Page 7: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/7.jpg)
7
Process
Detection Info View
DetectedClones View
DetectedClones View
Config Wizard
Results Text File Parser
CloneDR
EclipsePlatform
Clone Detection Results Plugin
AJDT Visualiser Plugin
1
23
3
3
1. Initially, user is assisted by detection process configuration wizard.2. CloneDR executes and generates a text file containing its results.
These results are parsed by the plugin.3. Detection statistics sent to information view and detected clones
sent to both textual and graphical view (step 3).
![Page 8: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/8.jpg)
8
Configuration Wizard
The detection of clones can run on all files or just on pre-selected files
The detection settings for CloneDR are also set in the wizard
Wizard generates a configuration file that will be used by CloneDR
![Page 9: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/9.jpg)
9
Detection Information Statistical information
about the clone detection procedure itself in addition to the configuration settings are displayed in the clone detection results information view.
![Page 10: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/10.jpg)
10
List of Clones Clone information:
grouped by similarity source file starting line number ending line number
Not new, Simian and SimScan plugins also provide similar reporting
![Page 11: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/11.jpg)
11
Visualiser View Bars: Source files Stripes (Kinds): Clones Mouse over:
Length of clone Other clones in the same
clone group
![Page 12: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/12.jpg)
12
Visualiser View
Additional Options: Display all bars containing the same clones as in
the selected bar Display all bars containing the selected clone Open the file containing the selected clone Open all files containing clones in the same clone
group as the selected clone
![Page 13: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/13.jpg)
13
Clone Refactoring
The Big Picture
RefactoredSource Files
Clone Detection
Detected Clones
Clone Analysis
Selected Clones for Refactoring
OriginalSource Files
Visualization /User Interaction
Programmer
![Page 14: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/14.jpg)
14
Case Study
Performed on open source applications JavaGenes, scientific evolutionary software JHotDraw, a GUI framework
Understanding the results Clone group in the same class (JavaGenes)
![Page 15: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/15.jpg)
15
Case Study
Understanding the results (continued) Ubitiquous clones (JHotDraw), methods that:
return a new Rectangle object draw two ovals (including setting their colors) setting the undo and redo flags for the drawing view
![Page 16: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/16.jpg)
16
Future Work
A more structured view of the source code files For OO languages, classes could be
displayed in UML-like form.
Demarcation of methods in bars representing source files Displaying the borders of methods in
the view can assist in determining which clones are method-level clones.
Tighter integration of CloneDR in Eclipse Simplify and speed up the detection
and visualization process. CloneDR
![Page 17: Visualization of Clone Detection Results](https://reader036.vdocuments.net/reader036/viewer/2022062315/5681509f550346895dbe9aef/html5/thumbnails/17.jpg)
17
Thank you. Questions?
Visualization of Clone Detection Results: http://www.cis.uab.edu/tairasr/visual
Clone Detection Literature: http://www.cis.uab.edu/tairasr/clones/literature
SoftCom Laboratory: http://www.cis.uab.edu/softcom