This project has moved. For the latest updates, please go here.

urgent About Clone Detective

Aug 6, 2012 at 10:38 AM

I use clonedetective for visual studio 2008,I tested 2  simple source code files  has 3 or 4 differences on their code lines in data types,literals and variables names and the remaining lines of code of 2 files are identical.The strange thing that it cannot detect these differences and it consider clone percentage 100%,So how it detect type I and type II CLONES? I felt that it just consider one file is clone to other but without detect or highlight differences is that true??also, when i try to see clone intersections they are the same,how?

Coordinator
Aug 8, 2012 at 2:29 AM
Edited Aug 8, 2012 at 2:30 AM

The default configuration requires 10 lines of consecutive code to be identical but you can customize that threshold in the settings.

From the help:

Minimum Clone Length. Sets the minimum length in lines of code that is needed for a clone. Clones that have fewer lines are discarded.

Does this help?

Aug 21, 2012 at 9:02 PM
Thanks for your help,but it doesnot work.I use 2 simple c# files which are almost identical and differs in 3 lines of code and i took into consideration that 10 lines of code consecutive have to be identical.Each file consists of 26 lines of code, the problem that it cannot determine number of cloned lines and it consider no of cloned lines =26 ,how come?it has to be 23 lines as there are 3 lines of code are not identical. I attached them to u in mail,plz if u have time tell me what is the problem of clone detective with me.

Thanks in Advance




From: [email removed]
To: [email removed]
Date: Tue, 7 Aug 2012 19:29:39 -0700
Subject: Re: urgent About Clone Detective [CloneDetectiveVS:390413]

From: terrajobst
The default configuration requires 10 lines of consecutive code to be identical but you can that threshold.
From the help:
Minimum Clone Length. Sets the minimum length in lines of code that is
needed for a clone. Clones that have fewer lines are discarded.
Does this help?
Read the full discussion online.
To add a post to this discussion, reply to this email (CloneDetectiveVS@discussions.codeplex.com)
To start a new discussion for this project, email CloneDetectiveVS@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Coordinator
Aug 22, 2012 at 12:23 PM

Well, it actually depends on what the differences in these 3 lines are. So, if they only differ because of an identifier or comments, then they are in fact part of a type II clone and Clone Detective correctly treats them as such.

On the other hand, if there are really different statements in these lines (e.g. in file A there's a method call statement like M(); and in file B there's an assignment statement like x=5;) then it's a bug in CD.

Unfortunately I didn't get your email so I really can't tell which case applies to your situation.

Regards, Thomas

Aug 22, 2012 at 9:47 PM

Thanks Thomas about your help,the differences in code i mean are in identifiers,data types,comments and literals.After ur comment I understood that CD considers them type II clones but i have a question now,given the following 2 source code files,there are 10 differences in 10 lines of code highlighted in red but when i use CD it detects only these 2 differences from below code ,

int result;                                                                                      float result;                                                         
int avg ;                                                                                        float avg ;

 and considered remaining lines clones and report that number of cloned lines=24 ,and number of lines =26,note i make minimum clone length =1 because i work on lines level.the question now why it detects only 2 differences although they are differ in data types and didnot detect others??and if it considers them all type II clones according to ur comment why it detects only 2 differences,considering ur reply it has to consider all 26 lines clones not 24 because they are differ in identifiers,data types,comments and literals.

really sorry for disturbance but i asked u in details because i use CD in my research.

 

class Program {                                                                             class Prog {
 public float  sumElement(float[] arr){                                              public int  sumElements(int[] arr){
 int sum = 0;                                                                                  int sum = 1;
 for (int i = 0; i < 5; i++)                                                                 for (int i = 0; i < 5; i++)
 {                                                                                                  {   
      sum += arr[i];                                                                          sum += arr[i];
 }                                                                                                   }
      return sum;                                                                              return sum;
 }                                                                                                   }
 static void Main(string[] args)                                                        static void Main(string[] args)    
 {                                                                                                  {
 Program p = new Program();                                                         Prog p = new Prog();
 int result;                                                                                      float result;                                                         
 int avg ;                                                                                        float avg ;
 int arr = new int[5];                                                                        float arr = new float[5];
 int size = arr.Length;                                                                     int size = arr.Length;
 Console.WriteLine("Enter numbers:");                                             Console.WriteLine("Enter numbers:");
 for (int i = 0; i < 5; i++)                                                                 for (int j = 0; j < 5; j++)                                         
 arr[i]=int.Parse(Console.ReadLine());                                               arr[j]=int.Parse(Console.ReadLine());                                           
 // sum of array elements                                                               // sum of array elements
 result= p.sumElements(arr);                                                           result= p.sumElements(arr);
// average of array elements                                                          // average of array elements
 avg=result/size;                                                                             avrg=result/size;
 Console.WriteLine("Addition is:"+ result);                                         Console.WriteLine("Addition is:"+ result);
 Console.WriteLine("Average is:"+ avg);                                            Console.WriteLine("Average is:"+ avg);
}}                                                                                                   }}