An array variable is initialized with new and a type that its declaration already gives

tx0/java:explicit-array-initializerstrictwarningstyle

What it finds

int[] primes = new int[] {2, 3, 5}; repeats the type that the declaration states; int[] primes = {2, 3, 5}; means the same.

Reported is a variable declared with an array type whose initializer is new T[] {...}. The fix drops new T[].

From the rule's source, explicit_array_initializer.rs.

Example from the rule's tests
class Primes {  int[] primes = new int[] {2, 3, 5};tx0 reports: the initializer alone says the same  int[] more = {7, 11};  Object values = new int[] {1};}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:explicit-array-initializer" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:explicit-array-initializer] reason="..."

tx0 explain tx0/java:explicit-array-initializer shows the same in the terminal. Found a false positive? Report it.