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

S3900 FP: Re-assignment of parameters is ignored #2591

Closed
saciervo opened this issue Aug 16, 2019 · 2 comments · Fixed by #7039
Closed

S3900 FP: Re-assignment of parameters is ignored #2591

saciervo opened this issue Aug 16, 2019 · 2 comments · Fixed by #7039
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@saciervo
Copy link

Description

Code in question:

public string Foo(string name)
{
    if (name == null)
    {
        name = Guid.NewGuid().ToString("N");
    }

    return string.Join("_", name.Split(Path.GetInvalidFileNameChars()));
}

Sonar C# falsely complains about the parameter name not getting validated.

Repro steps

You can clone this repo to reproduce the error. The project won't compile.

Expected behavior

No complaints, because there is a null-check in place.

Actual behavior

Code is marked as non-compliant

Known workarounds

None, besides suppression

Related information

  • SonarC# Version: 7.16.0.8981
  • Visual Studio Version: 2019 (16.2.0)
@andrei-epure-sonarsource andrei-epure-sonarsource added this to the Support milestone Aug 23, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource changed the title S3900 false positive S3900 FP when value is re-assigned Aug 23, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource added Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Area: Symbolic Execution Type: False Positive Rule IS triggered when it shouldn't be. Type: Bug Exceptions and blocking issues during analysis. labels Aug 23, 2019
@andrei-epure-sonarsource
Copy link
Contributor

thanks @saciervo I confirm the FP

@andrei-epure-sonarsource andrei-epure-sonarsource modified the milestones: Support, CFG + Symbolic Execution Aug 23, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource changed the title S3900 FP when value is re-assigned S3900 FP when string value is re-assigned Aug 27, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource removed the Type: Bug Exceptions and blocking issues during analysis. label Sep 24, 2019
@costin-zaharia-sonarsource costin-zaharia-sonarsource removed this from the CFG + Symbolic Execution milestone Dec 2, 2019
@Eli-Black-Work
Copy link

We're seeing this as well.

@pavel-mikula-sonarsource pavel-mikula-sonarsource added Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules. and removed Type: False Positive Rule IS triggered when it shouldn't be. labels Jun 25, 2021
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title S3900 FP when string value is re-assigned S3900 FP: when string value is re-assigned Oct 14, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 8.56 milestone Feb 27, 2023
@martin-strecker-sonarsource martin-strecker-sonarsource changed the title S3900 FP: when string value is re-assigned S3900 FP: Re-assignment of parameters is ignored Apr 5, 2023
@martin-strecker-sonarsource martin-strecker-sonarsource removed this from the 8.56 milestone Apr 18, 2023
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. Area: CFG/SE CFG and SE 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.

7 participants