Removing code does not trigger unused imports code smell

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) Sonarqube Enterprise Edition Version 9.9 (build 65466)
  • how is SonarQube deployed: zip, Docker, Helm
  • what are you trying to achieve
  • what have you tried so far to achieve this

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

We trigger SonarQube PR analyses in our build pipeline, and we are experiencing that the Quality Gate metrics are not enforced.

When removing code and creating a PR that only consists of removing code (leaving behind the - now - unused imports), the SonarQube scanner reports no code smells.

Extra info - we have disabled the setting that only PRs with more than 20 lines of new code will be analyzed.

Is this working as intended?

Unfortunately, these issues don’t get raised on pull requests, as they typically don’t involve a changed line (the issue is raised on the import, which hasn’t changed, not whatever was removed).

We’d like to improve this and you can vote for this roadmap item.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.