Skip to content

Commit

Permalink
Add Repro for issue #6449
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory-paidis-sonarsource committed Jan 12, 2023
1 parent 202b97a commit 559df68
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace Tests.Diagnostics
Expand Down Expand Up @@ -55,6 +56,20 @@ private static ArgumentNullException GetArgumentExpression(string name)

public class ValidCases
{
// https://github.com/SonarSource/sonar-dotnet/issues/6449
public class Repro_6449
{
public Task<int[]> CheckAsync() => Task.FromResult(new int[] { 1 });
public Task<int> Check2Async() => Task.FromResult(1);

public async Task HasS4457Async(int request) // Noncompliant, FP
{
var identifierType = (await CheckAsync()).FirstOrDefault(x => x == request);
if (identifierType == 0)
throw new ArgumentException("message"); // Secondary
}
}

public static Task FooAsync(string something)
{
if (something == null) { throw new ArgumentNullException(nameof(something)); }
Expand Down

0 comments on commit 559df68

Please sign in to comment.