Restricting SonarQube to Show code duplicate only in the Same file

Hi Team,
We are using SonarQube Enterprise 9.9 we have a GitHub repo where we store all the individual Python scripts and we are using sonarqube for code quality testing. In this scenario we are getting code duplicate by comparing with other files.

Question is :-- is their any way we can restrict code duplication check only withing the file.
Help is much appreciated


Hey there.

It’s not possible to limit duplication detection just within one file.

Can you give an example where there is a lot of acceptable duplication between files that you don’t want to abstract away?

Hi @Colin ,
If we are saving individual shell or bash scripts in a GitHub repo we are getting the code duplicate as their may be lot of blocks which are duplicated. as it is a separate file and executed separately we don’t need to find code duplicate by comparing with other files.

Hope you understand the scenario.