jeffsvajlenko / BigCloneEval

BigCloneEval - A Clone Detection Tool Evaluation Framework for BigCloneBench
GNU General Public License v2.0
73 stars 17 forks source link

EvaluateTool fails to consider imported clones #15

Open stonecauldron opened 4 years ago

stonecauldron commented 4 years ago

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?

qw3ry commented 4 years ago

Can check a few values in the report, please:

stonecauldron commented 4 years ago

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;
    }