Skip to content

Commit

Permalink
CloneDetectionRoutines: Prefer big code clones
Browse files Browse the repository at this point in the history
This reduces the calculated difference value for pairs of bigger clones.
This makes sense as bigger function with the same relative difference
are more likely to provide a refactoring opportunity than small
functions. As a result of this change small functions are less likely to
be recognized as clones which is a good property mirroring the real
usefulness in theory. As the testsuite still passes this change does not
break existing testcases, as more are added, the usefulness of this
change will be evaluated.
  • Loading branch information
sils committed Jun 24, 2015
1 parent d506bd3 commit 1df6aad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bears/codeclone_detection/ClangCloneDetectionBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ClangCloneDetectionBear(GlobalBear):
def run(self,
dependency_results: dict,
max_clone_difference: float=0.42):
max_clone_difference: float=0.33):
'''
Checks the given code for similar functions that are probably
redundant.
Expand Down
2 changes: 1 addition & 1 deletion bears/codeclone_detection/CloneDetectionRoutines.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ def compare_functions(cm1, cm2): # pragma: no cover

# If max_sum is zero diff_sum should be zero so division by zero can't
# occur here.
return diff_sum/max_sum
return (diff_sum/max_sum) * ((3*max_sum+1)/(4*max_sum))

0 comments on commit 1df6aad

Please sign in to comment.