>
>
>
V3173. Possible incorrect initializatio…


V3173. Possible incorrect initialization of variable. Consider verifying the initializer.

The analyzer detected a potential error that a variable or property initialization is missed.

Consider the example:

class A
{
  int field1;
  string field2;
  string field3;
  ....
  public void foo(int value)
  {
    field1 = value;
    field2 =                    // <=
    field3 = GetInitialization(value);
  }
}

In this case, the developer postponed the 'field2' initialization hoping that the code wouldn't compile and thus would remind of a missed initialization. But the code compiled successfully. 'field2' is assigned the value of 'field3'.

A similar situation may occur during a declaration, such as:

int b, c;

int a = 
b = c = 2;

This code looks suspicious. It is unclear what the author wanted to use to initialize the 'a' variable.

The analyzer will not issue a warning in a number of cases where it is clear that the code is written this way on purpose.

For example, there is indentation relative to the first line:

var1 =
  var2 = 100;

Here is another example with no indentation, but the value is written in several variables in the same way:

var1 =
var2 =
var3 =
var4 = 100;