Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negative duplicate-code when similarities are in the same file #1457

Open
onilton opened this issue Apr 27, 2017 · 8 comments
Open

False negative duplicate-code when similarities are in the same file #1457

onilton opened this issue Apr 27, 2017 · 8 comments
Labels
duplicate-code Related to code duplication checker Enhancement ✨ Improvement to a component False Negative 🦋 No message is emitted but something is wrong with the code Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@onilton
Copy link

onilton commented Apr 27, 2017

Steps to reproduce

  1. Create a file with repeated code: code.py
  2. 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

@PCManticore PCManticore added the Enhancement ✨ Improvement to a component label May 13, 2017
@guettli
Copy link

guettli commented Mar 5, 2018

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?

@Amegon
Copy link

Amegon commented Mar 13, 2018

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

@wdpypere
Copy link

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.

@iacopy
Copy link

iacopy commented Mar 9, 2020

Up!

@Pierre-Sassoulas Pierre-Sassoulas added Needs PR This issue is accepted, sufficiently specified and now needs an implementation False Negative 🦋 No message is emitted but something is wrong with the code labels Jun 30, 2022
@Pierre-Sassoulas Pierre-Sassoulas changed the title Similarities in the same file False negative duplicate-code when similarities are in the same file Jun 30, 2022
@Pierre-Sassoulas
Copy link
Member

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

#7439 (comment) @dgutson

@dgutson

This comment was marked as off-topic.

@dgutson
Copy link

dgutson commented Sep 9, 2022

@Pierre-Sassoulas is this about symilar? Does --enable=similarities end up calling symilar?

@Pierre-Sassoulas
Copy link
Member

Yes, symilar is embeded in pylint and raises duplicate-code messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate-code Related to code duplication checker Enhancement ✨ Improvement to a component False Negative 🦋 No message is emitted but something is wrong with the code Help wanted 🙏 Outside help would be appreciated, good for new contributors Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

9 participants