Issue: Add a way to break out of this method’s recursion.
False Positive
Rationale: This is coming back as a Recursion Blocker but after reviewing the code it looks like the method is calling a method of the same name with different params, ultimately not being a recursive method.
SonarQube Server / Developer
/// <summary>
/// Evaluates secondary solutions from a collection of solutions.
/// </summary>
/// <param name="solutions">The collection of solutions.</param>
/// <returns>A list of secondary solutions.</returns>
public static List<Solution> EvaluateSecondarySolutions(this IEnumerable solutions, bool checkOnhold = true)
{
return solutions.AsQueryable().EvaluateSecondarySolutions();
}
/// <summary>
/// Evaluates secondary solutions from a queryable collection of solutions.
/// </summary>
/// <param name="solutions">The queryable collection of solutions.</param>
/// <returns>A list of secondary solutions.</returns>
public static List<Solution> EvaluateSecondarySolutions(this IQueryable<Solution> solutions, bool checkOnhold = true)
{
var secondarySolutions = new List<Solution>();
foreach (var solution in solutions)
{
// Business Logic
secondarySolutions.Add(solution);
}
return secondarySolutions;
}
In the given code, a non-generic IEnumerable is passed to AsQueryable, resulting in a non-generic IQueryable. This non-generic IQueryable implements at compile time IEnumerable but not IQueryable<Solution>, so the call to EvaluateSecondarySolutions is recursive.
I believe @jilles-sg is correct and that this is a TP.
Within Visual studio we can see that for the given functions we can see that the call is recursive from the IEnumerable to the IEnumerable: