We're are using PMD and Checkstyle (from developers IDE and central CI server) to check code to our coding conventions.
I was expecting for these tools to provide a rule that checks for class members order but they don't seem to have one.
By class member order I mean something like:
public static properties
public properties
protected properties
private properties
public constructors
protected constructors
private constructors
static methods
non-static methods
I could certainly write my own PMD rule but I'm not used of it and would prefer not reinventing the wheel.
Do you know any tool that could do this kind of checks for us?
Checkstyle actually does that: DeclarationOrder
You can use Checkstyle's Declaration Order Check
Checks that the parts of a class or interface declaration appear in the order suggested by the Code Conventions for the Java Programming Language.
1.Class (static) variables. First the public class variables,then the protected, then package level (no access modifier), and then the private.
2.Instance variables. First the public class variables, then the protected,then package level (no access modifier), and then the private.
3.Constructors 4.Methods
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With