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

Fix S2259 FP/FN: Do not raise on Nullable members #6840

Closed
pavel-mikula-sonarsource opened this issue Mar 2, 2023 · 0 comments · Fixed by #6886
Closed

Fix S2259 FP/FN: Do not raise on Nullable members #6840

pavel-mikula-sonarsource opened this issue Mar 2, 2023 · 0 comments · Fixed by #6886
Assignees
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@pavel-mikula-sonarsource
Copy link
Contributor

In the context of S2259 and S3655, we need to split their responsibility for handling nullable types.

S2259 should not raise on

  • nullable.HasValue
  • nullable.Value
  • nullable.GetValueOrDefault()
  • nullable.Equals(..)
  • nullable.ToString()
  • nullable.GetHashCode()

as those are safe to call when nullable has ObjectConstraint.NullValue, or handled by S3655.

It should still raise on

  • nullable.GetType()
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: VB.NET VB.NET 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.

4 participants