Javascript module import reported as duplication

I have an issue that Sonarqube discovered newly added imports as duplications. I found this topic but the attached issue link reference to non-existent page.

  • What language is this for?
    Javascript

  • Which rule?
    Duplication scan

  • Why do you believe it’s a false-positive?
    The import of common module is marked as duplication. But I moved common code to common.js file to mitigate duplications to have same source twice in two files.

  • Are you using

    • SonarQube Server - Enterprise Edition v2025.1.3 (110580)
  • How can we reproduce the problem?

    First file - main.js

    image

    Second file - main.js in different location

    image

    Implementation is common.js file

    image

    The main.js file is imported as module in our main.php and common.js is only imported to main javascript files.

    image

I see only possible way to add files to duplication exclusion list. But this does not solve issue and the duplications will not be scanned for whole file anymore. Has not been the issue already solved? How can I solve it?

I may be wrong, I found the duplication is reported on line where logOff is called. Why the line is not shown when I click on New Code → Duplicated Lines in the left menu? It confuse me.

After I moved entire code block from main.js to logOff method the sonar analysis passed. Sorry for confusion.