Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S2589 FP with nullable value types #5221

Closed
csaba-sagi-sonarsource opened this issue Dec 28, 2021 · 2 comments · Fixed by #7750
Closed

S2589 FP with nullable value types #5221

csaba-sagi-sonarsource opened this issue Dec 28, 2021 · 2 comments · Fixed by #7750
Assignees
Labels
Area: C# C# rules related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@csaba-sagi-sonarsource
Copy link
Contributor

Description

S2589 raises a false positive when used with nullable value types.

Repro steps

protected void Test(decimal? value1, decimal? value2)
{
    if (value1 == null || value2 == null || value1 != value2)
    {
        Console.WriteLine("test");
    }
}

Expected behavior

No issue is raised.

Actual behavior

An issue is riased.

Related information

  • C#/VB.NET Plugins version: 8.33.0.40503
@csaba-sagi-sonarsource csaba-sagi-sonarsource added Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules. Area: C# C# rules related issues. labels Dec 28, 2021
@shuebner
Copy link

shuebner commented Jun 1, 2022

S2589 will trigger on null, too, e. g.

int? foo = (int?)6 ?? null;

@andrei-epure-sonarsource andrei-epure-sonarsource changed the title Fix S2589 FP with nullable value types S2589 FP with nullable value types Oct 14, 2022
@mary-georgiou-sonarsource mary-georgiou-sonarsource added this to the 9.7 milestone Jul 24, 2023
@martin-strecker-sonarsource martin-strecker-sonarsource modified the milestones: 9.7, 9.8 Aug 4, 2023
@mary-georgiou-sonarsource
Copy link
Contributor

Fixed by #7750

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants