-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FPs and FNs in the Symbolic Execution rules when null coalescing is combined with arithmetic expressions because we do not support constraints on integers #2528
Comments
This is most likely a duplicate of #2361 which got fixed during this sprint, it needs to be reviewed and confirmed it got fixed. |
@andrei-epure-sonarsource I had a look and this is not actually a duplicate of #2361. The issue here comes from the fact that we do not support constraints on integers in the symbolic execution engine. A simpler reproducer for this FP:
|
Another repro for this FP on community. And this can also manifest as a False Negative in S2583/S2589, e.g.
|
Another repro, from #4537
|
@pavel-mikula-sonarsource I guess after adding this reproducer, the title should be updated as well? currently it's "... because we do not support constraints on integers" ? LE: actually I saw your update on the #4537 (comment) , so there's a separate ticket tracking this (#4537) |
Can confirm we're also seeing this in our source. We don't want to disable SS2259, but alternatives are either suppressing in source (gross), or adding redundant null checks (annoying). Please consider finding a way to address this soon, it's been two years since it was initially reported. |
I am also facing same error while using sonar cloud on below line. What would be fix from sonar cloud? Var httpconnectextension= httpAccrssor.HttpContext==null?null: Httpconnectextension.current; |
We should take #4537 first to see if it fixes this one too |
When an IF statement uses the null conditional rule and (or?) the null coalescing operator then the else path is not marked as cannot be null, resulting in false S2259 messages.
Eg.
In this example, the line
text = $"{x.value} items";
gets a message S2259 'x' is null on at least one execution path.
Unless I'm misunderstanding something, that is not true.
The text was updated successfully, but these errors were encountered: