Skip to content

Commit

Permalink
Merge pull request #14 from blingenf/develop
Browse files Browse the repository at this point in the history
corrected issue causing pairs to appear in output report twice
  • Loading branch information
blingenf authored May 15, 2022
2 parents cf10fd3 + 437db09 commit a53eca5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions copydetect/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,14 @@ def get_copied_code_list(self):
x,y = np.where(self.similarity_matrix[:,:,0] > self.display_t)

code_list = []
file_pairs = set()
for idx in range(len(x)):
test_f = self.test_files[x[idx]]
ref_f = self.ref_files[y[idx]]
if (ref_f, test_f) in file_pairs:
# if comparison is already in report, don't add it again
continue
file_pairs.add((test_f, ref_f))

test_sim = self.similarity_matrix[x[idx], y[idx], 0]
ref_sim = self.similarity_matrix[x[idx], y[idx], 1]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_compare(self):
html_out = detector.generate_html_report(output_mode="return")

# verify highlighting code isn't being escaped
test_str1 = "data[2] = [</span>0<span class='highlight-red'>, 6, 1]"
test_str2 = "data[2] = [</span>3<span class='highlight-green'>, 6, 1]"
test_str1 = "data[2] = [</span>0<span class='highlight-"
test_str2 = "data[2] = [</span>3<span class='highlight-"
# verify input code is being escaped
test_str3 = "print(&#34;Incorrect num&#34;"
assert test_str1 in html_out
Expand Down

0 comments on commit a53eca5

Please sign in to comment.