Skip to content

Commit

Permalink
Apply Tim's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource committed Jul 4, 2024
1 parent 5913fad commit 6d75ee2
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ private static ProgramState[] ProcessLinqEnumerableAndQueryable(ProgramState sta

private static ProgramState[] ProcessElementExistsCheckMethods(ProgramState state, IInvocationOperationWrapper invocation)
{
if (invocation.GetInstance(state) is { } instance && ElementExistsCheckMethods.Contains(invocation.TargetMethod.Name) && instance.TrackedSymbol(state) is { } instanceSymbol)
if (ElementExistsCheckMethods.Contains(invocation.TargetMethod.Name) && invocation.GetInstance(state) is { } instance && instance.TrackedSymbol(state) is { } instanceSymbol)
{
return state[instanceSymbol]?.Constraint<CollectionConstraint>() switch
{
CollectionConstraint constraint when constraint == CollectionConstraint.Empty => state.SetOperationConstraint(invocation, BoolConstraint.False).ToArray(),
CollectionConstraint constraint when constraint == CollectionConstraint.NotEmpty && HasNoParameters(invocation.TargetMethod) =>
state.SetOperationConstraint(invocation, BoolConstraint.True).ToArray(),
CollectionConstraint constraint when constraint == CollectionConstraint.NotEmpty => state.ToArray(),
CollectionConstraint constraint when constraint == CollectionConstraint.NotEmpty =>
HasNoParameters(invocation.TargetMethod)
? state.SetOperationConstraint(invocation, BoolConstraint.True).ToArray()
: state.ToArray(),
_ when HasNoParameters(invocation.TargetMethod) =>
[
state.SetOperationConstraint(invocation, BoolConstraint.True).SetSymbolConstraint(instanceSymbol, CollectionConstraint.NotEmpty),
Expand Down

0 comments on commit 6d75ee2

Please sign in to comment.