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 657cf78
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))

2 comments on commit 657cf78

@fneu
Copy link
Contributor

@fneu fneu commented on 657cf78 Jun 24, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack in general.

have you thought about making the difference value dependent on the size of the function? For me it sounds like you keep shifting the focus around and maybe this could yield better results across the board.

@sils
Copy link
Member Author

@sils sils commented on 657cf78 Jun 24, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.