Hi there,
For the following example code:
String[] array = {"A", "B", "C"};
The variable name is annotated with the warning “Declare this local variable with “var” instead. | sonarlint(java:S6212)”.
If the code is amended as follows:
var array = {"A", "B", "C"};
A compiler error results: “Array initializer needs an explicit target-type | Java(16778722)”
In fact, according to JEP 286 (emphasis added):
Poly expressions that require such a type, like lambdas, method references, and array initializers, will trigger an error.
Hence, this is positively a false positive
Thanks,
ADTC