Multiple variable declared on the same line
1package io.tofpu.speedbridge2.model.support.worldedit;
2
3public class Vector {
4 private final double x, y, z; 5
6 public Vector(final double x, final double y, final double z) {
7 this.x = x;
Multiple variable declared on the same line
1package io.tofpu.speedbridge2.model.support.worldedit;
2
3public class Vector {
4 private final double x, y, z; 5
6 public Vector(final double x, final double y, final double z) {
7 this.x = x;
Multiple variable declared on the same line
3import io.tofpu.multiworldedit.VectorWrapper;
4
5public final class CuboidRegion {
6 private final VectorWrapper minVector, maxVector; 7
8 public CuboidRegion(final VectorWrapper minVector, final VectorWrapper maxVector) {
9 this.minVector = minVector;
Multiple variable declared on the same line
6import java.util.UUID;
7
8public enum PlayerStatType {
9 TOTAL_WINS, TOTAL_TRIES;10
11 public static PlayerStat create(final UUID owner, final PlayerStatType playerStatType) {
12 return create(owner, playerStatType, "0");
Multiple variable declared on the same line
242 }
243
244 public enum LeaderboardRetrieveType {
245 GLOBAL, SESSION;246 }
247}
248
Multiple variable declared on the same line
44 }
45
46 public enum IslandFactoryType {
47 REGULAR, BUILD;48 }
49}
Multiple variable declared on the same line
1package io.tofpu.speedbridge2.model.common.wrapper;
2
3public enum FileConfigurationType {
4 YAML, HOCON;5}
Multiple variable declared on the same line
41 }
42
43 for (int i = 0; i < Math.min(firstSplit.length, secondSplit.length); i++) {
44 int currentValue = NumberUtils.toInt(firstSplit[i]), newestValue = NumberUtils.toInt(secondSplit[i]); 45
46 if (newestValue > currentValue) {
47 return second;
Multiple variable declared on the same line
41 }
42
43 for (int i = 0; i < Math.min(firstSplit.length, secondSplit.length); i++) {
44 int currentValue = NumberUtils.toInt(firstSplit[i]), newestValue = NumberUtils.toInt(secondSplit[i]); 45
46 if (newestValue > currentValue) {
47 return second;
Multiple variable declared on the same line
35
36 /** The default version scheme for this update checker */
37 public static final VersionScheme VERSION_SCHEME_DECIMAL = (first, second) -> {
38 String[] firstSplit = splitVersionInfo(first), secondSplit = splitVersionInfo(second); 39 if (firstSplit == null || secondSplit == null) {
40 return null;
41 }
Multiple variable declared on the same line
167 }
168
169 enum ModifyItemType {
170 SELECTED, LACK_PERMISSION;171 }
172}
Multiple variable declared on the same line
450 }
451
452 public enum ResetType {
453 ALL, SCORES, STATS454 }
455}
Multiple variable declared on the same line
450 }
451
452 public enum ResetType {
453 ALL, SCORES, STATS454 }
455}
Description
Multiple variables (or fields) should not be declared on the same line.
Declaring more than one variables (or fields) on the same line makes the code harder to read. Things might get more confusing if some of those variables are initiliazed and some of them are not.
Bad Practice
class Klass {
private int a, b = 20;
private void method() {
double d1, d2 = 3.5, d3;
// ... rest of the code
}
}
Recommended
Consider declaring one variable per line.
class Klass {
private int a;
private int b = 20;
private void method() {
double d1;
double d2 = 3.5;
double d3;
// ... rest of the code
}
}