We are using Sonarqube Developer EditionVersion 8.9.9 (build 56886) and we have a problem with the code duplication process in SonarQube where we cannot think of the best solution.
When we used the import statement, Sonarqube identified it as duplicated code. But we need to import those dependencies into each file.
Also, there are some instances where we want the exact code structure in different files by passing different values. But SonarQube captures it as a duplicate code without reading the passing values.
Also, we noticed that when we use the same code line in multiple files, it is captured as a duplicate code.
I appreciate your support in figuring this out.
Welcome to the community!
Are you interpreting the yellow highlight as a duplication marker? Because it’s not. The yellow highlight indicates code that has been added or edited in the New Code Period.
Thank you for the response.
Sorry for the confusion there. Didn’t mean to indicate highlighted lines as duplicates.
We want to have the same line of code in multiple files in some scenarios (Ex: import …). When we push the code with that sort of requirement, SonarQube captures it as duplication code. Can we avoid that cross-file duplication-checking?
Your best option is to set duplications exclusions. Unfortunately, by doing that, you’ll exclude the entire file from duplications detection.
BTW, just for clarity, what language is this?
Thanks for the information.
We are using Node.js (typeScript).