Skip to content

Commit

Permalink
Review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-paidis-sonarsource committed Feb 13, 2024
1 parent 05ad94d commit 1d1adca
Showing 1 changed file with 8 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,27 +96,13 @@ public static CollectionConstraint ArrayCreationConstraint(IArrayCreationOperati
? CollectionConstraint.Empty
: CollectionConstraint.NotEmpty;

public static ProgramState LearnFrom(ProgramState state, IMethodReferenceOperationWrapper operation)
{
if (operation.Instance is not null
&& operation.Instance.Type.DerivesOrImplementsAny(CollectionTypes)
&& AddOrRemoveMethods.Contains(operation.Method.Name))
{
state = state[operation.Instance] is { } operationValue
? state.SetOperationValue(operation, operationValue.WithoutConstraint<CollectionConstraint>())
: state;

state = operation.Instance.TrackedSymbol(state) is { } symbol && state[symbol] is { } symbolValue
? state.SetSymbolValue(symbol, symbolValue.WithoutConstraint<CollectionConstraint>())
: state;

return state;
}
else
{
return state;
}
}
public static ProgramState LearnFrom(ProgramState state, IMethodReferenceOperationWrapper operation) =>
operation.Instance is not null
&& operation.Instance.Type.DerivesOrImplementsAny(CollectionTypes)
&& AddOrRemoveMethods.Contains(operation.Method.Name)
&& state[operation.Instance] is { } value
? state.SetOperationAndSymbolValue(operation.Instance, value.WithoutConstraint<CollectionConstraint>())
: state;

public static ProgramState LearnFrom(ProgramState state, IPropertyReferenceOperationWrapper operation, ISymbol instanceSymbol)
{
Expand All @@ -136,7 +122,7 @@ public static ProgramState LearnFrom(ProgramState state, IPropertyReferenceOpera
state = state.SetOperationConstraint(operation, NumberConstraint.From(0, null));
}
}
if (operation.Property.IsIndexer)
else if (operation.Property.IsIndexer)
{
state = state.SetOperationConstraint(operation.Instance, CollectionConstraint.NotEmpty);
if (instanceSymbol is not null)
Expand Down

0 comments on commit 1d1adca

Please sign in to comment.