This inspection reports cases of switch statements that will never be executed according to the results of integer value analysis. The inspection only works if Analyze integer arithmetic is enabled on the Code Inspection | Settings page of ReSharper options Alt+R, O.
Here is an example of annotating the method parameter with [NonNegativeValueAttribute] to refine the analysis within the method body. Knowing that the parameter is non-negative, ReSharper can report redundant cases:
voidTestSwitch([NonNegativeValue]int input){int newValue;switch(input){case0:
newValue =1;break;case-1:// Case is heuristically unavailable
newValue =0;break;default:
newValue = input;break;}}
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.