-
Notifications
You must be signed in to change notification settings - Fork 238
Open
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.
Description
Description
SonarQube should not recommend reverting IDE0031 after the fix is applied to the following code. (using <LangVersion>preview</LangVersion>, which will become <LangVersion>14</LangVersion> in a couple weeks.)
class Foo {
Foo? child;
public void DoSomething(Foo? other) {
if (other != null) // IDE0031: Simplify null check
other.child = this;
}
}
The automatic fix for IDE0031 changes this code to the reproducer below.
Reproducer
class Foo {
Foo? child;
public void DoSomething(Foo? other) {
other?.child = this; // Unexpected S1121
}
}
Expected behavior
S1121 should not be raised on null-forgiving assignments.
Product and Version
SonarQube 8.26.0.14275 on Visual Studio 17.14.15 and Windows 11 24H2.
bart-vmware, arjenkeijzer and KuraiAndras
Metadata
Metadata
Assignees
Labels
False PositiveRule IS triggered when it shouldn't be.Rule IS triggered when it shouldn't be.