.. _duplicate-code: duplicate-code / R0801 ====================== **Message emitted:** ``Similar lines in %s files %s`` **Description:** *Indicates that a set of similar lines has been detected among multiple file. This usually means that the code should be refactored to avoid this duplication.* **Problematic code:** ``__init__.py``: .. literalinclude:: /data/messages/d/duplicate-code/bad/__init__.py :language: python ``apple.py``: .. literalinclude:: /data/messages/d/duplicate-code/bad/apple.py :language: python ``orange.py``: .. literalinclude:: /data/messages/d/duplicate-code/bad/orange.py :language: python **Correct code:** ``__init__.py``: .. literalinclude:: /data/messages/d/duplicate-code/good/__init__.py :language: python ``apple.py``: .. literalinclude:: /data/messages/d/duplicate-code/good/apple.py :language: python ``fruit.py``: .. literalinclude:: /data/messages/d/duplicate-code/good/fruit.py :language: python ``orange.py``: .. literalinclude:: /data/messages/d/duplicate-code/good/orange.py :language: python **Additional details:** If you need to make a change to the logic or functionality of the duplicated code, you will need to identify all the places that need to be changed, which can be time-consuming and error-prone. If there are multiple copies of the same code, then you will also need to test each copy to ensure that the functionality is correct. Duplicate code can be confusing for someone who is trying to understand the logic and flow of the code if they come across multiple identical or nearly identical blocks of code. The reader can then skim and think something is identical when it actually isn't. This is particularly true during review. Created by the `similarities `__ checker.