- Operating system: Win 10-64
- SonarLint plugin version: 7.1.0.75242
- Is connected mode used: No
The purpose of S3440
is to detect useless checks before assignment such as if (a != b) a = b;
I changed a code section from a switch statement to a switch expression, and S3440
appeared.
Consider this code:
var type = (previous) switch
{
DataPrefixType.AlphaLower => DataPrefixType.AlphaLower,
DataPrefixType.RomanLower => DataPrefixType.RomanLower,
_ => DataPrefixType.AlphaOrRomanLower
};
The purpose is to evaluate previous
to see what we should set type
to. However, because the evaluation and the set are the same values, the rule is firing.
Again, when written as a switch statement, the rule does not fire.