pylint
pylint copied to clipboard
False negative ``duplicate-code`` when similarities are in the same file
Steps to reproduce
- Create a file with repeated code: code.py
- pylint --disable=all --enable=similarities code.py
Current behavior
Do not show code repeated in the same file,
Expected behavior
Show code repeated in the same file.
pylint --version output
I do not understand this issue.
I used similarities today for the first time, and it worked.
Could you please provide an example where pylint fails to find the duplicates?
similarities compares code lines among multiple files. if you have one file with duplicated code it will not be found. Attached is a modification of pylint checkers similar.py to also compare a file with itself (if only one file is given to pylint) maybe this helps you to use that feature or to add it in the future, after making it to clean code again similar.zip
this would be nice to have. I enabled similarities expecting checking in the same file was the actual behaviour. I was a bit surprised it only works on multiple files.
Up!
Maybe this could be also a command line flag --scan-self and yet provide a list of file names, meaning that similarity scanning will also occur within each provided file
https://github.com/PyCQA/pylint/issues/7439#issuecomment-1241510155 @dgutson
CC @qequ
@Pierre-Sassoulas is this about symilar? Does --enable=similarities end up calling symilar?
Yes, symilar is embeded in pylint and raises duplicate-code messages.