-
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 S1067 FP: Conditionals in pattern should not be considered as a unit for the whole pattern #6429
Comments
Preliminary Peach validation until AX0U1INEAng_OcXOZhgF: Lost: Tenary operator condition (Not exactly defined by the RSpec)if the conditions appear in the "Condition" of the ternary, then the ternary is ignored, because we do not step only into the WhenTrue and WhenFalse part but not the Condition part. var userId = user != null && user.UserID > 0 && !user.IsDeleted && (showSuperUsers || !user.IsSuperUser)
? user.UserID
: 0; Lost: XOR (Not specified by the RSpec)Lost: Nested in other binary expressionTernary is on the right-hand side of a recheck =
inlining.numLdloc.GetOrDefault(v) != 1 ||
inlining.numLdloca.GetOrDefault(v) != totalElementCount + (expr.Code == ILCode.Call ? 1 : 0)) ||
(inlining.numStloc.GetOrDefault(v) != (expr.Code == ILCode.Call ? 0 : 1));
|
do you plan to make a fix for these @martin-strecker-sonarsource (as it was a side-effect of the refactoring)? |
For the first one we need to do something (the condition part of an outermost ternary is not checked at all at the moment). For the others, I would define other binaries as "transparent" (except maybe XOR, |
I agree that invocation arguments start a new root. |
Second peach validation run: if directive conditionsThe rule should not raise in Issue #6574 |
Description
In pattern like this:
The
or
patterns are counted as a single group and S1067 is raised because more than 3or
are present. Because the two checks don't belong together directly the property patterns should be considered a "conditional root". Also, note that other sub-pattern kinds are also roots (declaration pattern, var pattern, list pattern, and maybe more).Some test cases were added in #6428
C# 11 list pattern are also affected
The text was updated successfully, but these errors were encountered: