javaeclipsecheckstyle

Checkstyle - One Declaration per line aligned to a block


i'm trying to configure Eclipse Checkstyle but I can't find the option for two things:

in methods i want for each declaration a new line:

public int calc (int x, 
                 int y,
                 int z) {
}

and NOT:

public int calc (int x, int y, int z) {
}

and declarations should be wrapped like this

private var                a;
private int []             b = null;
private ArrayList<Integer> c = new ArrayList<Integer> ();

and NOT:

private var a;
private int [] b = null;
private ArrayList<Integer> c = new ArrayList<Integer> ();

I already tried the "MultipleVariableDeclarations" and the OneStatementPerLine but those work only inside of methods not for the Parameters of a method.

I hope someone can help me.


Solution

  • I don't think there are build-in Checkstyle rules for that. The build-in rules aim to maintain a style that is common and established. Like @yegor256 already said, yours isn't. You can browse this site for any checks that match your requirement. I couldn't find any. As a last option you can always write your own check.

    A tip for the code formatter: Go to Window->Preferences and filer for Save Actions. There you can define that your code should always be formatted on save. Maybe you don't need a tool like Checkstyle to warn you about unformatted code then.