Skip to content

Commit

Permalink
S2259: Add FP repro for #6241
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-mikula-sonarsource committed Oct 25, 2022
1 parent d2590e5 commit 97e5295
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1666,3 +1666,33 @@ private void WithExpression(System.Linq.Expressions.Expression<Func<object>> exp
private object WithDelegate(Func<IEnumerable<object>, object> expression) => null;
private void WithDelegate(Func<object> expression) { }
}

// https://github.com/SonarSource/sonar-dotnet/issues/6241
public class Repro_6241<T>
{
public void WithGenericValue()
{
HashSet<T> value = null;
if (value is null)
{
value.ToString(); // FN
}
else
{
value.ToString(); // Noncompliant FP
}
}

public void WithNormalValue(List<object> inputs)
{
HashSet<object> value = null;
if (value is null)
{
value.ToString(); // Noncompliant
}
else
{
value.ToString(); // Compliant
}
}
}

0 comments on commit 97e5295

Please sign in to comment.