S2583 - Casting boolean with is results in false positive

private static string getStringVal(object value)
	if (value is bool boolVal)
		return boolVal ? "1" : "0";
	return null;

SonarCloud will flag return boolVal ? "1" : "0"; with:

Bug: Change this condition so that it does not always evaluate to 'true'; some subsequent code is never executed.

Hello Stephen,

Thank you for reporting this issue. We confirm this as false positive, there already exists this issue to track it.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.