Code Clone Analysis Tool: ICCA
Yoshiki Higo†，Norihiro Yoshida†，Toshihiro Kamiya‡，Shinji Kusumoto†，Katsuro Inoue††Graduate School of Information Science and Technology, Osaka University，‡National Institute of Advanced Industrial Science and Technology

Code Clone••Cloning Relation

A code fragment that has identical or similar fragments in source files
Makes software maintenance more difficult

Code Clone– If we modify a code fragment and it has code clones, it is necessary toconsider whether or not we have to modify each of the code clones

Code Clone Detection Tool: CCFinder
1. static void foo() throws RESyntaxException {2. String a[] = new String [] { "123,400", "abc", "orange 100" };3. org.apache.regexp.RE pat = new org.apache.regexp.RE("[0-9,]+");
4. int sum = 0;
5. for (int i = 0; i < a.length; ++i)6.
if (pat.match(a[i]))7.
sum += Sample.parseNumber(pat.getParen(0));
8. System.out.println("sum = " + sum);
9. }10. static void goo(String [] a) throws RESyntaxException {11. RE exp = new RE("[0-9,]+");
12. int sum = 0;
13. for (int i = 0; i < a.length; ++i)14.
if (exp.match(a[i]))15.
sum += parseNumber(exp.getParen(0));
16. System.out.println("sum = " + sum);
17. }• Directly compares source code on token unit,
and detects code clones– Normalization of name space– Replacement of name defined by the user
– Removal of table initialization

1. static void foo() throws RESyntaxException {2. String a[] = new String [] { "123,400", "abc", "orange 100" };3. org.apache.regexp.RE pat = new org.apache.regexp.RE("[0-9,]+");
4. int sum = 0;
5. for (int i = 0; i < a.length; ++i)6.
if (pat.match(a[i]))7.
sum += Sample.parseNumber(pat.getParen(0));
8. System.out.println("sum = " + sum);
9. }10. static void goo(String [] a) throws RESyntaxException {11. RE exp = new RE("[0-9,]+");
12. int sum = 0;
13. for (int i = 0; i < a.length; ++i)14.
if (exp.match(a[i]))15.
sum += parseNumber(exp.getParen(0));
16. System.out.println("sum = " + sum);17. }• Outputs code clone information in text format• Analyzes the system of millions line scale in practical use time
• CCFinder Official Web Page: http://www.ccfinder.net/Code Clone Analysis Tool: ICCA
• Supports various scenarios on software maintenance• There are three sub-systems for each objective– Gemini: Visualizes code clone information for understanding– Aries: Supports refactorings of code clones– Libra: Supports modification of source code including code clones

ICCA (Integrated Code Clone Analyzer)• Distributes our tools (ICCA/CCFinder package) toindividuals and organization in different contories– Studies of code clones in research institute– Introductions into commercial software development in companies Source CodeCodeCodeCloneClone
Detection
Detection(CCFinder)(CCFinder)

Sub-system
Refactoring
RefactoringSupport
SupportAries

Visualization
Visualization
Characterization
Characterization

Gemini

Modification
ModificationSupport
Support

Libra

Code Clone• ICCA Official Web Page: http://sel.ist.osaka-u.ac.jp/icca/

Gemini Sub-system•

Visualizes code clone information•

Characterizes code clones and files using several metrics– The user can understand the state of code clones at a glance– Code clones appearing in a log of places of source code
– Files including a lot of code clones•

Filtering out code clones which is not importantAries Sub-system•

Identifies where should be refactored•

Suggests how each code clone can be refactored– detects refactoring-oriented code clones– Uses existing refactoring patterns• “Extract Method”，”Pull Up Method”, …

– Characterizes detected code clones using some metrics• The degree of code clone dispersion in the class hierarchy• The coupling between a code clone and its surroundings

Libra Sub-system••Prevents the user overlooking some code fragmentsin the modification process
Detects only code clones that are identical or similar
to the fragment input by the user
– For shortening detection time

contact address: y-higo@ist.osaka-u.ac.jp

User