Missing Code Smells in New Code

Hello,

We using SonarQube Data Center Edition Version 9.9

We intend to use the “Clean as You Code” strategy for PRs and would expect any code smells created by my new code to be displayed. Unfortunately, there are many examples of code smells not being displayed in the PR or the branch analysis under NewCode. This means that these code smells do not prevent the quality gate from failing.

The attached example shows that the change in line 220 leads to a code smell, which is displayed in line 208 (default case has been removed). An else-if was removed in line 250, which is then displayed in line 245. There are many other examples that make the new code look good but actually make the code worse.
In my opinion, the logic “Which code smells are displayed for the new code” should be improved here.
Currently, the “Clean as You Code” approach can only be used to a limited extent.
Are improvements planned here?

Hey there.

This is a known limitation that we report on PRs only issues on changed lines. We struggle with this internally as well (we just had an internal report of it today) where a PR was green, bu the Quality Gate was red when merged into the main branch.

We want to handle it this year. You can add your voice on this roadmap item: https://portal.productboard.com/sonarsource/3-sonarqube/c/295-new-pull-request-issues-on-unchanged-code?&utm_medium=social&utm_source=starter_share