A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/SonarSource/sonar-dotnet/issues/7462 below:

Codefix should set correct condition priority by adding parentheses. · Issue #7462 · SonarSource/sonar-dotnet · GitHub

The statement

obj == null ? false : obj.ToString() == "x" || obj.ToString() == "y";

get fixed to:

!(obj == null) && obj.ToString() == "x" || obj.ToString() == "y";

which throws null exception because the condition is evaluated as (condition1 && conction2) || condition3. (condition1 && conction2) is false and so condition3 will be evaluated.

It should be fixed to:

!(obj == null) && (obj.ToString() == "x" || obj.ToString() == "y");

so that the evaluation is condition1 && (condition2 || condition3) and if condition1 is false then (condition2 || condition3) won't be evaluated at all.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4