-
Notifications
You must be signed in to change notification settings - Fork 231
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 S4158 FN: Learn Empty on Clear #7861
Conversation
e42664c
to
b27e448
Compare
744acfa
to
9634fad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicks and questions
...nalyzer.UnitTest/TestCases/SymbolicExecution/Roslyn/EmptyCollectionsShouldNotBeEnumerated.cs
Show resolved
Hide resolved
@@ -531,6 +539,8 @@ public void LearnConditions_Size(bool condition, List<int> arg) | |||
var empty = new List<int>(); | |||
var notEmpty = new List<int>() { 1, 2, 3 }; | |||
|
|||
// the tests below are messy for as long as we unlearn CollectionConstraints on empty.Count() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty.Count()
will (wrongly) unlearn CollectionConstraint
due to it being an extension method. The UTs here do not take this into consideration and thus provide unexpected results. They should be fixed when Count()
does not unlearn anymore.
...yzer.Common/SymbolicExecution/Roslyn/RuleChecks/EmptyCollectionsShouldNotBeEnumeratedBase.cs
Outdated
Show resolved
Hide resolved
29004b0
to
844143f
Compare
@@ -195,7 +195,8 @@ private ProgramState ProcessInvocation(SymbolicContext context, IInvocationOpera | |||
} | |||
} | |||
return ProcessAddMethod(context.State, invocation.TargetMethod, instance) | |||
?? ProcessRemoveMethod(context.State, invocation.TargetMethod, instance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
Maybe you can retrieve once the invocation.TargetMethod.Name
and pass it to all the calls as an argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nitpick
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
Part of #7457
We do not learn
CollectionEmpty
fromlist.Clear()
.