Must-share information (formatted with Markdown):
- SonarQube - Version 6.7.2 (build 37468)
- Wish to ignore “Dead stores should be removed” code smell when assignment is to “default” value.
- Nothing yet…
Within C#, instead of declaring local variables with their datatype first, our team always uses the “var” syntax sugar. It is easier to see where variables are being declared if they all begin with “var”.
So instead of:
int x; SqlCommand command;
We declare it as:
var x = default( int ); var command = default( SqlCommand );
It is a few more characters but the creation and assignment of the local variable is more clear.
SonarQube reports this as a “useless assignment to local variable”, which I can assure you it is not.
Your documentation states that the following are initializations are exceptions:
* initializations to
I believe that you need to add “default” to your list of initialization exceptions.