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 S3900 FN: Conversion operations #7002

Merged
merged 10 commits into from
Mar 29, 2023
Prev Previous commit
Next Next commit
Add more test cases
  • Loading branch information
zsolt-kolbay-sonarsource committed Mar 29, 2023
commit f8d6f1006938db7bfc325d8fd3ee49cab0de133b
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,21 @@ public void UpCast(string s)
((object)s).ToString(); // Noncompliant
}

public void CastWithPropertyAccess(object o)
{
_ = ((Exception)o).Message; // Noncompliant
}

public void CastWithRedundantParentheses(object o)
{
(((string)o)).ToString(); // Noncompliant
}

public void MultipleCasts(object o)
{
((string)((object)((string)o))).ToString(); // Noncompliant
}

public void AsOperatorDownCast(object o)
{
(o as string).ToString(); // Noncompliant
Expand Down