Fix S4158 FP: The analyzer incorrectly concludes the HashSet is guaranteed to be empty #8041
Labels
Area: C#
C# rules related issues.
Area: CFG/SE
CFG and SE related issues.
Area: VB.NET
VB.NET rules related issues.
Type: CFG/SE FPs
Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone
Description
HashSet.Remove causes S4158 on an empty HashSet. It should not.
Repro steps
I tried to remove parts of this repro, but I could not make it cleaner without loosing the FP.
_ = toDoLater.Remove(item);
issues S4158Expected behavior
S4158 is not issued as the HashSet is not guaranteed to be empty
Actual behavior
S4158 is issued.
Known workarounds
Suppress the issued warning.
Related information
SonarAnalyzer version 9.7.0.75501
The text was updated successfully, but these errors were encountered: