-
Notifications
You must be signed in to change notification settings - Fork 222
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 S3878 FP: Jagged arrays #9102
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.
LGTM assuming SC analysis turns out ok after the pipeline is fixed.
@@ -95,7 +95,7 @@ public void CallMethod() | |||
MethodArray(new String[] { "1", "2" }, new String[] { "1", "2" }); // Noncompliant, FP. Elements in args: [System.String[], System.String[]] | |||
MethodArray(new int[] { 1, 2 }, new int[] { 1, 2 }); // Noncompliant, FP. Elements in args: [System.Int32[], System.Int32[]] | |||
|
|||
MethodJuggedArray(new int[] { 1, 2 }); // Noncompliant, FP. Elements in args: [System.Object[]] | |||
MethodJuggedArray(new int[] { 1, 2 }); // Compliant: jagged array [System.Object[]] |
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.
jugged :D
MethodJuggedArray(new int[] { 1, 2 }); // Compliant: jagged array [System.Object[]] | |
MethodJaggedArray(new int[] { 1, 2 }); // Compliant: jagged array [System.Object[]] |
: null; | ||
|
||
private static bool IsJaggedArrayParam(IParameterSymbol param) => | ||
param.Type is IArrayTypeSymbol { ElementType: IArrayTypeSymbol }; |
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.
param.Type
is always IArrayTypeSymbol
, correct? I wonder if a direct cast would be more explicit here. Then again... I like the pattern-matching syntax :D
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 swear I replied but I don't see the message now for some reason. Anyway not always, but in this particular implementation, we are checking previously that the parameter is an array. So yes, that part will always be true. But I would leave the pattern-matching because it's quite neat IMO
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.
Quality Gate passedIssues Measures |
Quality Gate passedIssues Measures |
Fixes #8163