1) group Fields with assigning to Anonymous classes;
private successListener = new Listener {
...
// some anonymous class definition, could be few methods definition
....
}
private int value;
private successListener2 = new new Listener {
...
// some anonymous class definition, could be few methods definition
....
}
Name for macros is Field_ann_class
2) Setter/Getter (base on bean notation). Notation detection was taken from https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/sevntu-checks/src/main/java/com/github/sevntu/checkstyle/checks/coding/SimpleAccessorNameNotationCheck.java
Marcos: Getter_setter
expected order of declarations - all get/set are grouped and not mixed with other methods of class.
public int setX(){}
public int getX(){}
public int setY(){}
public int getY(){}
3) Coverage of nested interfaces, nested enumerations
Macros: InnerInterfaces, InnerEnums.
public class MyClass {
interface CrazyInterface{ .... }
....
}
enum HiddenEnum{ .... }
....
}
}
4) Coverage nested classes in methods
Option that are "true" by default: ignoreInnerClassesInMethods
Example of bad code:
private methodX (...) {
class NameC{ ... }
...
}
Link to GitHub
--
You received this message because you are subscribed to the Google Groups "Sevntu Checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sevntu-checkst...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
https://github.com/baratali/sevntu.checkstyle/commit/40720b36a73b1257a8fe6d864ed064a77d8c3fd8
/*** Stack of lists to keep getter list for certain class definition.*/private Deque<List<DetailAST>> mGetters = new LinkedList<List<DetailAST>>();
if (!mCustomOrderDeclaration.isEmpty()) {mCustomOrderDeclaration.clear();}
String regExp;
switch(aInputMemberName) {case "field":
public void setIgnoreRegExCase(final boolean aCaseInsensitive){if (aCaseInsensitive) {
else {defaultTokens[index] = defaultTokens[0];}
mObjectBlockTokens.push(objBlock);mSetters.push(new ArrayList<DetailAST>());mGetters.push(new ArrayList<DetailAST>());
&& !(mIgnoreInnerClassesInMethods&& isClassDefInMethodDef(aAST)))
if (mClassStates.isEmpty()) {mClassRoot = true;}
/*** Examine method definition. If it is getter or setter,* then adds this method to collection.* @param aMethodDefAst DetailAST of method definition.*/private void findGetterSetter(DetailAST aMethodDefAst) {
if (nameOfGettingField != null&& verifyFieldAndMethodName(nameOfGettingField,methodName))
/*** Use for recursive tree traversal from first child of current tree top.** @param aAST current DetailAST state, first child of current tree top.* @return the unit modifiers and annotation list.*/private String concatLogic(final DetailAST aAST)
public void setValue(int newValue) {
validate()
value = newValue;
}
public void setObj(Object obj) {
if (!initialized) {
throw Exception();
}
this.obj = obj;
}
2) private boolean mCheeckInnerClasses;
typo
3)
private boolean mIgnoreInnerClassesInMethods = true;
I lost a reason of this option to be FALSE, do not remember this , lets discuss.
4)
public void setIgnoreRegExCas
lets discuss, I do not like this to be setter for mCompileFlags, or I do not like name of it.
Why set of it was skip in first IF in that method?
5)
Parsing input line with custom declaration order into massive.
What is massive ?
6)
mClassDetails.push(new ClassDetail());
Very strange code. We need to postpone pushing empty object to the point where it is going to be used, or lets discuss
7)
if (mCheckGettersSetters) {collectGetterSetter(aAST);}logWrongOrderedElement(aAST);
Log warnings without condition ?
it have to be
if (isWrong(...))
{
logWrong(....)
}
8)
* Returns true when getter is correct.
Doc have to explain what is "correct" getter, your decision is subjective I pretty sure. The same for setter.
--
You received this message because you are subscribed to the Google Groups "Sevntu Checkstyle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sevntu-checkst...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
private static String getNameOfSetterField(DetailAST aAssignAst)
It now could get methodCallAst, and not only assignAst, so, this method should be splitted to 2 parts to avoid mixing different logic branches:
one part for processing assign node, another - for processing method calls.
final DetailAST leftPart = assignAst.getFirstChild();
It is always a DOT ast, please name it appropriately
/*** Verify that exists assignment to field among statements.* @param aStatementsAst DetailAST of statements (SLIST).* @param aFieldName name of target field.* @return true if there is assignment to aFieldName in aStatementsAst.*/private static boolean isFieldUpdate(DetailAST aStatementsAst, String aFieldName)
DetailAST nextStatement = currentStatement.getFirstChild();while ((currentStatement != null) && (nextStatement == null)) {nextStatement = currentStatement.getNextSibling();if (nextStatement == null) {currentStatement = currentStatement.getParent();}}