Skip to content

Commit

Permalink
[duplicate-code] Remove trailing whitespaces in similarity report
Browse files Browse the repository at this point in the history
And fix tests/checkers/unittest_similar.py that required to have some
  • Loading branch information
Pierre-Sassoulas committed Jul 1, 2021
1 parent c983d7d commit d1048a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Release date: TBA

Closes #4648

* The ``similarity`` checker no longer add three trailing whitespaces for
empty lines in its report.


What's New in Pylint 2.9.2?
===========================
Expand Down
2 changes: 1 addition & 1 deletion pylint/checkers/similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _get_similarity_report(self, similarities: List[Tuple]) -> str:
report += f"=={line_set.name}:{idx}\n"
if line_set:
for line in line_set._real_lines[idx : idx + number]:
report += f" {line.rstrip()}\n"
report += f" {line.rstrip()}\n" if line.rstrip() else "\n"
duplicated_line_number += number * (len(files) - 1)
total_line_number: int = sum(len(lineset) for lineset in self.linesets)
report += "TOTAL lines={} duplicates={} percent={:.2f}\n".format(
Expand Down
2 changes: 1 addition & 1 deletion tests/checkers/unittest_similar.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_ignore_signatures_fail():
arg5: int = 5
) -> Ret1:
pass
def example():
"""Valid function definition with docstring only."""
TOTAL lines=29 duplicates=10 percent=34.48
Expand Down

0 comments on commit d1048a1

Please sign in to comment.