Param/var set conditionally in code block doesn't totally discard initial value

Rule javascript:S1226 (BUG) states: Function parameters, caught exceptions and foreach variables’ initial values should not be ignored.
However, when a parameter value is only conditionally overridden, the initial value is not completely ignored; it is only ignored in certain possibly-rare cases. When this conditional override happens inside a block bound by curly braces {…}, Sonarqube flags the issue in what is actually a false positive:

function demonstrateNonCompliant(param1, param2 = false) {
	{
		if(typeof param1 === 'undefined') {
			param2 = true; //False positive BUG flag here
		}
		//...
		if(param2) {
			//do something else
		}
	}
}

function demonstrateCompliant(param1, param2 = false) {
	//Not starting try { here to avoid NEW BUG failure in Sonarqube
		if(typeof param1 === 'undefined') {
			param2 = true;
		}
		//...
		if(param2) {
			//do something else
		}
	//Not using } catch (err) {... here to avoid NEW BUG failure in Sonarqube
}

Sonarqube version: Version 8.9.5 (build 50698)

Hi Ben,

I see the confusion and indeed if you read the rule title, initial value is not always ignored. But if you read the rule description even if the parameter overwritten only conditionally it’s still a drawback in the maintainability. You better create a new variable to be explicit that under some conditions parameter should be adjusted. In a perfect world we would report a code smell in your case and a bug when parameter is always re-assigned, but that’s not possible.

And as usual you can always won’t fix the issue if you are convinced that in this case you don’t want to be hassled with an additional variable.

This is title and rule behavior we are having for all languages, so I don’t feel necessary to change anything.