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.
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?
Is there a similar method of ignoring code blocks in typescript as shown below for Java. My quality gate is failing due to using the same nestjs decorators for a number different controllers, I would prefer not to exclude the entire file from duplication checking if possible?
public class MyClass {
public MyClass() {
...
}
public void doSomething() {
...
}
// BEGIN-NOSCAN
public void doSomethingElse()
{
...
}
// END-NOSCAN
}
We try to keep it to one topic per thread. Otherwise, things get messy, fast.
//NOSONAR is implemented on a language-by-language basis, and not for all languages. So my guess would be ‘no’. If you want to discuss it further, please create a new thread.