Skip to content

Commit 2d16e61

Browse files
mary-georgiouSonarTech
authored andcommitted
NET-2385 S1172: Add FP repro
GitOrigin-RevId: af96e5ef048bcdc010290354158b7a3dcc7588d6
1 parent 9654f35 commit 2d16e61

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

analyzers/tests/SonarAnalyzer.Test/TestCases/MethodParameterUnused.Latest.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,26 @@ private static string CaptureSimple(string text) // Compliant
477477
}
478478
}
479479
}
480+
481+
namespace ReproNET2384
482+
{
483+
class Test
484+
{
485+
// https://sonarsource.atlassian.net/browse/NET-2384
486+
void Method(string? a, string? b) // Noncompliant FP for string? b. The b value is read if a is null
487+
{
488+
LocalFunction();
489+
void LocalFunction()
490+
{
491+
if (a != null)
492+
{
493+
b = null; // modify b only if a is not null
494+
}
495+
if (b != null)
496+
{
497+
//...
498+
}
499+
}
500+
}
501+
}
502+
}

0 commit comments

Comments
 (0)