Skip to content

Commit

Permalink
Fix FP S3878: #6893 and #6894 (#9395)
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource authored Jun 20, 2024
1 parent 444559d commit 02cdbf2
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 389 deletions.
160 changes: 0 additions & 160 deletions analyzers/its/expected/Ember-MM/S3878-Ember Media Manager.json

This file was deleted.

28 changes: 0 additions & 28 deletions analyzers/its/expected/Ember-MM/S3878-generic.EmberCore.NMT.json

This file was deleted.

82 changes: 0 additions & 82 deletions analyzers/its/expected/Ember-MM/S3878-multi.EmberExtras.json

This file was deleted.

52 changes: 0 additions & 52 deletions analyzers/its/expected/Ember-MM/S3878-scraper.EmberCore.XML.json

This file was deleted.

This file was deleted.

12 changes: 6 additions & 6 deletions analyzers/src/SonarAnalyzer.CSharp/Rules/ArrayPassedAsParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ public sealed class ArrayPassedAsParams : ArrayPassedAsParamsBase<SyntaxKind, Ar
protected override ILanguageFacade<SyntaxKind> Language => CSharpFacade.Instance;

protected override SyntaxKind[] ExpressionKinds { get; } =
{
[
SyntaxKind.ObjectCreationExpression,
SyntaxKind.InvocationExpression,
SyntaxKindEx.ImplicitObjectCreationExpression
};
];

protected override ArgumentSyntax LastArgumentIfArrayCreation(SyntaxNode expression) =>
LastArgumentIfArrayCreation(ArgumentList(expression));

private static ArgumentSyntax LastArgumentIfArrayCreation(BaseArgumentListSyntax argumentList) =>
argumentList is { Arguments: { Count: > 0 } arguments }
ArgumentList(expression) is { Arguments: { Count: > 0 } arguments }
&& arguments.Last() is var lastArgument
&& IsArrayCreation(lastArgument.Expression)
? lastArgument
: null;

protected override ITypeSymbol ArrayElementType(ArgumentSyntax argument, SemanticModel model) =>
model.GetTypeInfo(((ArrayCreationExpressionSyntax)argument.Expression).Type.ElementType).Type;

private static BaseArgumentListSyntax ArgumentList(SyntaxNode expression) =>
expression switch
{
Expand Down
Loading

0 comments on commit 02cdbf2

Please sign in to comment.