-
Notifications
You must be signed in to change notification settings - Fork 228
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
SE: Learn from bool collection methods #9497
Conversation
718a236
to
b37cf25
Compare
a79e9b0
to
9cb7d94
Compare
@@ -236,7 +234,6 @@ public static int NonLinqExtensionNullChecking(this IEnumerable<int> source) | |||
|
|||
[DataTestMethod] | |||
[DataRow("Count")] | |||
// [DataRow("Any")] |
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.
These cases at this point need their own test - not sure if it worths it.
@@ -49,11 +49,9 @@ public void InstanceReference_SetsNotNull_VB() | |||
|
|||
[DataTestMethod] | |||
[DataRow("Aggregate", "(x, y) => x")] | |||
//[DataRow("Any")] |
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.
These cases at this point need their own test - not sure if it worths it.
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.
Review Round 1
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/Extensions/IInvocationOperationExtensions.cs
Outdated
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/Extensions/IInvocationOperationExtensions.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.cs
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.Enumerable.cs
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.Enumerable.cs
Outdated
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.Enumerable.cs
Outdated
Show resolved
Hide resolved
006d2fa
to
776f880
Compare
analyzers/src/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.cs
Outdated
Show resolved
Hide resolved
return states.SelectMany(x => new List<ProgramState> | ||
{ | ||
x.SetOperationConstraint(invocation, ObjectConstraint.Null), | ||
x.SetOperationConstraint(invocation, ObjectConstraint.NotNull) | ||
}).ToArray(); |
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.
don't review this - it will change in the next PR.
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
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.
Looks pretty good already - a few comments, but nothing major.
.../tests/SonarAnalyzer.Test/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Invocation.cs
Outdated
Show resolved
Hide resolved
.../tests/SonarAnalyzer.Test/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Invocation.cs
Outdated
Show resolved
Hide resolved
.../tests/SonarAnalyzer.Test/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Invocation.cs
Outdated
Show resolved
Hide resolved
.../tests/SonarAnalyzer.Test/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Invocation.cs
Outdated
Show resolved
Hide resolved
.../tests/SonarAnalyzer.Test/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Invocation.cs
Outdated
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/Extensions/IInvocationOperationExtensions.cs
Outdated
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/Extensions/IInvocationOperationExtensions.cs
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.Enumerable.cs
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.Enumerable.cs
Outdated
Show resolved
Hide resolved
...c/SonarAnalyzer.Common/SymbolicExecution/Roslyn/OperationProcessors/Invocation.Enumerable.cs
Outdated
Show resolved
Hide resolved
6d75ee2
to
24e22d7
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.
I replied to the outstanding suggestions from the first review.
.../tests/SonarAnalyzer.Test/SymbolicExecution/Roslyn/RoslynSymbolicExecutionTest.Invocation.cs
Outdated
Show resolved
Hide resolved
Quality Gate passed for 'Sonar .NET Java Plugin'Issues Measures |
Quality Gate passed for 'SonarAnalyzer for .NET'Issues Measures |
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, you can add the UTs for the extension method in a follow-up.
@@ -42,4 +42,10 @@ internal static class IInvocationOperationExtensions | |||
|| (invocation.TargetMethod.IsExtensionMethod | |||
&& !invocation.Arguments.IsEmpty | |||
&& state.ResolveCaptureAndUnwrapConversion(invocation.Arguments[0].ToArgument().Value).Kind == OperationKindEx.InstanceReference); | |||
|
|||
public static IOperation GetInstance(this IInvocationOperationWrapper invocation, ProgramState state) => |
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.
You could improve coverage by adding UTs for this extension method. This would be good practice in general. I'm sorry I missed mentioning this earlier.
Related to #8266 and #7457