Failing a build in the IDE for new code violations

We are using C# and would like to achieve something similar to the above. Currently I see warnings in the IDE which then require a CI run to fail the build on new code violations.

What is the recommendation here (if any) to improve that cycle time?

We are using SonarCloud in connected mode. I can change the rule severity but not with an option of Error (is that possible?). The severity options are info, minor, major, critical & blocker. A critical error in SonarLint is shown only as a warning in Visual Studio 22.

Any guidance on how to improve this would be greatly appreciated.

Hi @OliB - welcome to the community.

I’ve split your post out to a new thread (please don’t post to existing threads, particularly ones that are several years old. Instead, start a new thread and if appropriate refer to the existing thread).

At present, your best option is probably to use the built-in VS “Changed Documents” filter in the Error List:

However, that will show you all of the issues in the changed files, rather than the new issues since the last commit/new issues in the current working branch.
We have a feature in the roadmap for this year to show only the new issues in the IDE i.e. the same issues that would be reported in a CI run.

No, it is not possible. The mappings from Sonar severities to VS severities are shown here. They are not currently configurable in Connected Mode. Most projects have many pre-existing issues, so we don’t want to set the severity to Error as that would prevent developers from building locally.

If you use standalone mode you can set the severities to whatever you like.