Change C# Rules

Is there a way of updating/changing rules? One of the C# rules suggests that having an If statement which does not check all possible values is invalid and there should be a final else statement to catch any value not checked in the if statement. However, to me this is wrong. I can think of many cases where this is perfectly valid code. e.g. My variable X may have a value from 1 to 10. In all cases I need to apply some function irrespective of the value of x but if x is 1 or 2 do something extra. SonarQube marks this as a issue but it is a perfectly valid condition.

Create custom quality profile, remove the rule from the quality profile.

1 Like