Fix your Quality Gates today to maximise impact

Hello SonarCloud :sonarcloud: users,

Context
Your quality gate may be missing some conditions on the new code. Or having a very relaxed threshold. These can lead to a situation where quality gate status may give you a false sense of cleanliness. Gradually the technical debt in your overall code will creep up over time.

We made it easy to fix
Now you can navigate to your quality gate page and look for the option: Review and Fix this Quality Gate.

Screenshot 2024-02-12 at 14.16.38

You will be able to review and understand what conditions will be added and what thresholds will be changed. As you fix your quality gate, SonarCloud will also offer the opportunity to remove redundant conditions that will no longer be needed.

Note
Conditions on the overall code will not be changed.

Learn more about Configuring a quality gate for Clean as You Code

Best Regards,
SonarCloud Team

3 Likes

That’s nice but because of the way that percentage based measures work, they rarely make sense to use with Gitlab on branches.

For example, if I deprecate 5 different methods and that is the only change in my MR, my “Maintainability” rating will likely be an “E” and I will be unable to merge that MR, even if my overall maintainability would still be an “A” after merging that change.

Another example - if I make a 10 line change, and I want to only cover 5 of those lines - giving me 50% code coverage on new code - giving me a total code coverage on all of my code of 95%, my branch could still fail if I have a coverage goal of 80% on new code.

Hello Derek,

Thanks for your feedback.

For maintainability issues that you may not want to address ‘now’ but will fix later (such as deprecation), the current workflow is to ‘accept’ those issues. This resolution will pass your quality gate.

If 80% coverage in new code is difficult to achieve for your team, you may choose a lower thresold (Eg: 50%).

Thanks @vivek.reghunath for that suggestion! If I “Accept” the issues on the MR, my understanding is that:

  • They will no longer be visible on the main/master branch (existing code)
  • They will no longer count towards my overall maintainability rating on existing code

Is that correct?

Hello @james2

  • They will no longer be visible on the main/master branch (existing code)

Accepted issues will not be visible in issue list pages by default - you can still see them by changing the “Resolution” filter from “Unresolved” (default value) to “Accepted”. Moreover, SonarCould will display in the pull request and in each branch summary page the total number of accepted issues (see an example here) to help you quantify the technical debt.

  • They will no longer count towards my overall maintainability rating on existing code

That’s correct.

1 Like

Hi @Marco_Comi Thanks again for the discussion here, it is helpful.

I still have one point of confusion. In this thread Dismiss Issues Marked as “Accepted” - #9 by Marco_Comi we talked about accepted issues still having an impact on Technical debt (sqale_index ) or Maintainability rating (sqale_rating ), but in the reply above you stated that accepted issues will not count towards the overall maintainability rating.

Could you please clarify?