Limiting Type of Code Smells Committed

Hi,

I’m testing out sonarcloud for my team, and I feel really good about the options for quality gating across almost all the dimensions except code smells.

What I’d really like to do is not let people commit major code smells, or ideally not let them commit them if they’re easy to remediate.

The current tech debt ratio, setup actually incentivizes the opposite it seems because if it’s easy to remediate, it lowers your tech debt score and makes it easier to commit it.

But if it’s a major smell and it’s easy to fix, I’d rather our users do that before they merge.

Would it be possible to set up a gate like the other ratings where A = 0 smells, B = 1 minor smell, etc. so that we could basically require that at the bar minimum no one commits major smells?

I’m seeing too many junit out of order assertions slip through and they’re very easy to fix :slight_smile:

Hi,

Welcome to the community!

Ehm… We don’t have severity metrics per issue type. So there’s no way to set a Quality Gate condition on, E.G. Major Code Smells, much less one on Major Code Smells on New Code.

What you can do is set a condition on Major Issues on New Code. Since you’re presumably already cleaning up Major Bugs and Vulnerabilities, in practice it equates to the same thing.

 
HTH,
Ann

1 Like

That’s where I landed as soon as I posted this, so good to hear that’s the preferred route!

I do think it would be interesting to come up with a metric that’s somewhat inverted from what you have as I mention, where if the tech debt time to fix is low relative to the PR size, we can push them to clean it up rather than allowing it through. I’d be a happy consumer of such a metric. But for the time being I’m all set with the major issues limitation.

1 Like