Several variables are declared in one declaration

tx0/java:multiple-declaratorsstrictwarningstyle

What it finds

int width, height = 0; reads as if both were set to 0, but only height is, and int[] a, b[] gives the two variables different types. One variable per declaration leaves no doubt.

Reported is a field or local variable declaration with more than one variable, outside the head of a for loop.

From the rule's source, multiple_declarators.rs.

Example from the rule's tests
class Sizes {  int width, height = 0;tx0 reports: a second variable   void run() {    int a = 1, b = 2;tx0 reports: a second variable    for (int i = 0, j = 0; i < j; i++) {      a += i;    }  }}
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:multiple-declarators" = "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:multiple-declarators] reason="..."

tx0 explain tx0/java:multiple-declarators shows the same in the terminal. Found a false positive? Report it.