BigCloneEval icon indicating copy to clipboard operation
BigCloneEval copied to clipboard

EvaluateTool fails to consider imported clones

Open stonecauldron opened this issue 5 years ago • 2 comments

I want to evaluate a tool with BigCloneEval.

To this end, I started with a single file to ensure that the whole pipeline works without issue. I ran my tool on BinarySearch.java.

Here are the detected clone pairs:

sample,BinarySearch.java,6,6,sample,BinarySearch.java,19,19
sample,BinarySearch.java,6,16,sample,BinarySearch.java,19,29
sample,BinarySearch.java,6,16,sample,BinarySearch.java,32,45
sample,BinarySearch.java,6,16,sample,BinarySearch.java,48,60
sample,BinarySearch.java,19,29,sample,BinarySearch.java,32,45
sample,BinarySearch.java,19,29,sample,BinarySearch.java,48,60
sample,BinarySearch.java,32,32,sample,BinarySearch.java,48,48
sample,BinarySearch.java,32,45,sample,BinarySearch.java,48,60

Following the README instructions, I registered a new tool, imported the pairs reported in the above file and ran the evaluateTool command in the following way.

./evaluateTool -t 1 -o report -st both -mis 0 -mil 6 -mip 6 -mit 50 -m "CoverageMatcher 0.7"

In the generated report recall is equal to 0 for every clone type despite the clone pairs in BinarySearch.java having been correctly detected.

I manually checked the tools database and the pairs were imported without issue.

Do you know what could be causing this problem? Are the parameter values I am using in evaluateTool inappropriate?

stonecauldron avatar Nov 25 '19 09:11 stonecauldron

Can check a few values in the report, please:

  • Line 4 of the report should say something like #Clones: 8, as you imported 8 clones.
  • Around line 35, the recall for all functionalities is listed per clone type. It has the format <#detected> / <#total> = <recall>. Is it correct that both "#detected" and "recall" are 0 for all types?

qw3ry avatar Dec 13 '19 12:12 qw3ry

Thank you for getting back to me.

Line 4 of the report does indeed say that 8 clones were successfully.

My problem comes from the fact that the recall in the report is equal to 0, despite some of the clones in sample/BinarySearch.java having been detected by my tool.

For example, the pair below was classified as a clone by my tool:

sample,BinarySearch.java,6,16,sample,BinarySearch.java,19,29

In code this pair corresponds to these two BinarySearch functions which are indeed clones:

public static int binarySearch1(int arr[], int key, int imin, int imax) {
		//Implementation: Recursive, primitive type
		if(imax < imin)
			return -1;
		int imid = (imin+imax)/2;
		if(arr[imid] > key)
			return binarySearch1(arr,key,imin,imid-1);
		else if (arr[imid] < key)
			return binarySearch1(arr,key,imid+1,imax);
		else
			return imid;

public static <T extends Comparable<T>> int binarySearch3(T[] arr, T key, int imin, int imax) {
		//Implementation: Recursive, comparable type
		if(imax < imin)
			return -1;
		int imid = (imin+imax)/2;
		if(arr[imid].compareTo(key) > 0)
			return binarySearch3(arr,key,imin,imid-1);
		else if (arr[imid].compareTo(key) < 0)
			return binarySearch3(arr,key,imid+1,imax);
		else
			return imid;
	}

stonecauldron avatar Dec 20 '19 10:12 stonecauldron