SonarC# 7.3 Collection elements should not be replaced unconditionally" False Positive Problem

Hello,

S4143 Rule causes a lot of issues throughout our application analyses, however, most of them are false positive. This rule is unable to detect object creations sometimes, so it raises false issues like the following:

 dr["CurrencyCode"] = General.GeneralParametersFinder.LocalCurrencyCode();
 dt.Rows.Add(dr);
 dr = dt.NewRow();
 dr["CurrencyCode"] = Framework.GeneralParameters.E_U_R;  // False issue raised here. dr refers to a new DataRow because of the previous line

Note: dr is DataRow, and dt is DataTable

Hi @Alpay_KAPTAS,

Thank you for the feedback, this indeed is a FP. I have created an issue to fix it.

Cheers,
Amaury

1 Like

As far as I understand, the issue you created is closed. Have you resolved this problem? I upgraded sonar to 7.3 version but we stil have these false issues.

Thank you

Hi @Alpay_KAPTAS,

If you look at the ticket you will see that it is associated to the milestone/release 7.4 so you will need to update to version 7.4 to get this fix.

Cheers,
Amaury

1 Like