- which versions are you using (SonarQube)
- what are you trying to achieve
Get rule csharpsquid:S4462 to block my quality gate.
- what have you tried so far to achieve this
Insert code that is exactly what the rule complains about.
public static ICollection AddContext(this ICollection services)
var respository = services.GetRequiredService<IRepository>();
return new Context
Value = Task.Run(() => respository.GetCurrent()).GetAwaiter().GetResult()
services.AddScoped<IContext>((services) => services.GetRequiredService<IContextSetter>());
You can’t set Quality Gate conditions on specific rules. What you can do is set conditions on categories of rules. For instance, I see that by default S4462 is a Blocker. So you could set a condition on the number of Blocker issues.
Thanks for your answer. To make it clear, the condition is not blocking the quality gate because Sonarqube does not see this rule on that snipped of code, there is no issue thrown in any of our applications. 0 issues on rule csharpsquid:S4462 in arround 3/4 million lines of code, thats a llitlebit strange.
Okay! So this is actually a report of a false negative. I missed that in the discussion of failing the Quality Gate.
I’ve moved this to the FP/FN category & I’ll ping the language team.
Rule S4462 is not enabled by default (see defaultQualityProfiles). You need to extend your quality profile to activate the rule. You can find more information about how to do it in the documentation.
Best regards, Martin
Perfect thank you that worked for me.