The OneDeclarationPerLine rule really checks for maximum one declaration per statement, not one per line. But Java allows for multiple declarations to each be on individual lines in a single statement -- and the rule currently disallows that.
I would agree that multiple declarations in one line can be hard to read. But I disagree that
String a = "first string"; String b = "second string"; String c = "third string";
is harder to read than
String a = "first string", b = "second string", c = "third string";
In fact, the second one is less cluttered. But it's a matter of style.
Relaxing the rule to permit one declaration on each line of a multi-line statement would at least make the name of the rule match its behavior.
Otherwise, please provide a parameter to allow the multi-line, single-statement form.
Log in to post a comment.