diff --git a/ChangeLog b/ChangeLog index ee1b82af53..818e08af1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -63,6 +63,10 @@ Release date: TBA Closes #4907 +* Setting ``min-similarity-lines`` to 0 now makes the similarty checker stop checking for duplicate code + + Closes #4901 + What's New in Pylint 2.10.3? ============================ diff --git a/doc/whatsnew/2.11.rst b/doc/whatsnew/2.11.rst index cdbba865d4..ac98463027 100644 --- a/doc/whatsnew/2.11.rst +++ b/doc/whatsnew/2.11.rst @@ -69,3 +69,7 @@ Other Changes * Fix false positive ``superfluous-parens`` for tuples created with inner tuples Closes #4907 + +* Setting ``min-similarity-lines`` to 0 now makes the similarty checker stop checking for duplicate code + + Closes #4901 diff --git a/pylint/checkers/similar.py b/pylint/checkers/similar.py index c65b1c8933..cb002c3db5 100644 --- a/pylint/checkers/similar.py +++ b/pylint/checkers/similar.py @@ -919,6 +919,8 @@ def Run(argv=None): ignore_signatures = True if not args: usage(1) + if min_lines == 0: + sys.exit(0) sim = Similar( min_lines, ignore_comments, ignore_docstrings, ignore_imports, ignore_signatures ) diff --git a/tests/checkers/unittest_similar.py b/tests/checkers/unittest_similar.py index 4ddf2029a2..c98ea15df5 100644 --- a/tests/checkers/unittest_similar.py +++ b/tests/checkers/unittest_similar.py @@ -502,3 +502,11 @@ def test_get_map_data() -> None: # There doesn't seem to be a faster way of doing this, yet. lines = (linespec.text for linespec in lineset_obj.stripped_lines) assert tuple(expected_lines) == tuple(lines) + + +def test_set_duplicate_lines_to_zero() -> None: + output = StringIO() + with redirect_stdout(output), pytest.raises(SystemExit) as ex: + similar.Run(["--duplicates=0", SIMILAR1, SIMILAR2]) + assert ex.value.code == 0 + assert output.getvalue() == ""