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: is is not considered as null-check #2775

Closed
andrei-epure-sonarsource opened this issue Nov 6, 2019 · 2 comments
Closed

S3900 FP: is is not considered as null-check #2775

andrei-epure-sonarsource opened this issue Nov 6, 2019 · 2 comments
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

@andrei-epure-sonarsource
Copy link
Contributor

Description

from community

Validation using is is not taken into consideration when chaining bool expressions.

Repro steps

    public class ReproWithIs
    {
        public override bool Equals(object obj)
        {
            var equals = (obj is string) && (obj.GetHashCode() == GetHashCode()); // Noncompliant FP
            if (equals)
            {
                // do stuff
            }
            return equals;
        }
    }

Known workarounds

Please provide a description of any known workarounds.

Related information

  • SonarQube 8.0
  • SonarC# 8.0
  • SonarScanner for MSBuild 4.7.1
  • MSBuild 15.9
@andrei-epure-sonarsource andrei-epure-sonarsource added Area: C# C# rules related issues. Area: Rules Type: False Positive Rule IS triggered when it shouldn't be. Type: Bug Exceptions and blocking issues during analysis. Area: CFG/SE CFG and SE related issues. labels Nov 6, 2019
@andrei-epure-sonarsource andrei-epure-sonarsource added this to the CFG + Symbolic Execution milestone Nov 6, 2019
andrei-epure-sonarsource added a commit that referenced this issue Nov 6, 2019
@pavel-mikula-sonarsource pavel-mikula-sonarsource removed Area: Rules Type: Bug Exceptions and blocking issues during analysis. labels Nov 29, 2019
@costin-zaharia-sonarsource costin-zaharia-sonarsource removed this from the CFG + Symbolic Execution milestone Dec 2, 2019
@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
@andrei-epure-sonarsource andrei-epure-sonarsource added the Type: False Positive Rule IS triggered when it shouldn't be. label Dec 24, 2021
@csaba-sagi-sonarsource csaba-sagi-sonarsource removed Type: False Positive Rule IS triggered when it shouldn't be. Area: CFG/SE CFG and SE related issues. labels Dec 28, 2021
@costin-zaharia-sonarsource
Copy link
Member

@andrei-epure-sonarsource andrei-epure-sonarsource changed the title Fix S3900 FP: is is not considered as null-check S3900 FP: is is not considered as null-check Oct 14, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource added this to the 8.56 milestone Feb 27, 2023
@pavel-mikula-sonarsource
Copy link
Contributor

Fixed by #6793

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

No branches or pull requests

4 participants