Fix S3900 FP: Don't raise if parameter is captured #7060
Labels
Area: C#
C# rules related issues.
Type: CFG/SE FPs
Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone
Description
S3900 is falsely raised when the parameter is captured:
Root cause
When we enter the block after the return,
s
has the NotNull constraint as expected.s
is also in thecaptured
list ofLiveVariableAnalysisBase
. Therefore it is not included in theLiveOut
list:And that is why it gets removed in
ProcessBranchState
:sonar-dotnet/analyzers/src/SonarAnalyzer.Common/SymbolicExecution/Roslyn/RoslynSymbolicExecution.cs
Lines 165 to 167 in 0d3caf3
The text was updated successfully, but these errors were encountered: