-
Notifications
You must be signed in to change notification settings - Fork 223
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
S1066: Add reproducer for #9221 #9264
Conversation
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 suggest adding more test cases.
dynamic anything = "2024-04-29"; | ||
|
||
if (anything is string) // Secondary | ||
if (DateTime.TryParseExact(anything, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dt)) // Noncompliant FP | ||
return dt; | ||
|
||
return null; |
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 would add more test cases based on what @pavel-mikula-sonarsource said about not raising if there is a dynamic in the statement:
if (notDynamic is not null)
if (notDynamic == "something" && anything is string) // Noncompliant (not sure if FP or not there)
return null;
if (notDynamic is not null)
if (notDynamic == "something") // Noncompliant (to make sure we do not deactivate S1066 for the whole block)
return null;
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!
Reproducer for #9221