Incorrect duplicate code block in javascript file

  • ALM used:
    GitHub
  • CI system used:
    GitHub Actions
  • Scanner command used (monorepo):
    mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
  • Languages of the repository:
    Java & JavaScript/TypeScript/HTML

I recently added a new module to my monorepo to scan my lambda functions and it is incorrectly citing a duplicate block in one of my files, where there is no duplicate. It is a switch statement with different cases which isn’t used anywhere else in my repo. Is there a way to ‘fix’ this? The weird thing is it says it is duplicated by the same block that it is referring to?

Hey there.

Can you provide a screenshot or code sample?


This is the only code like this in the whole repo.

Hey there.

Checkout this post:

Hi, I’m running into this exact same issue. Is there anyway we can get around this without excluding the entire file? Can we exclude the switch case code block?

I saw some other post about about “code block exclusions”, but I could not get it to work. There was mention of a UI to set this information, but I dont see this UI at all on my side. (Note, I’m set as ADMIN too).

Josh

Hi, This is an old post … but how did you get around this? I couldnt get exclusions to work for a specific code block and file exclusions is not something I want either. I need the rest of the file to be scanned.

Anyway, I just rewrote our switch-case blocks to using the Map object. I’m not to happy that I had to rewrite a switch-case statement, seeing that it’s a pretty fundamental feature of most languages.