Is there any library in python for duplicate code checker? I use python IDE and I am finding trouble refactoring my code. Are there any python library available which suggest duplicate code in the program/project?
Update: I found clone digger which as per its site,
We have tested Clone Digger on sources of several open-source projects. There are following drawbacks of the current report format:
Differences are highlighted using diff algorithm. This way of highlighting has nothing common with the abstract syntax tree based algorithm of comparing sequences of statements for similarity.
Class and function comments are taken into account during the computation of similarity, but they are not presented in the output. Therefore some clone pairs can look equal but marked as convergent.
Are there any tools better than this?
You can make use of a for-loop that we will traverse the list of items to remove duplicates. The method unique() from Numpy module can help us remove duplicate from the list given. The Pandas module has a unique() method that will give us the unique elements from the list given.
Press Ctrl+Alt+S to open the IDE settings and select Editor | Inspections. Select the Duplicated code fragment inspection under the General node. In the inspection options, select whether you want to view duplicates only within the same file or across the entire project.
Pylint has a check for similar/duplicate code: https://pylint.readthedocs.io/en/latest/technical_reference/features.html#similarities-checker
Usage:
pylint --disable=all --enable=similarities src/yourcode/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With