Add test coverage to LineWrappingHandler in Indentation check. #1270
This commit is contained in:
parent
e40d9f41cf
commit
2ff20f4af3
1
pom.xml
1
pom.xml
|
|
@ -1155,7 +1155,6 @@
|
|||
<regex><pattern>.*.checks.indentation.ArrayInitHandler</pattern><branchRate>87</branchRate><lineRate>100</lineRate></regex>
|
||||
<regex><pattern>.*.checks.indentation.ElseHandler</pattern><branchRate>75</branchRate><lineRate>100</lineRate></regex>
|
||||
<regex><pattern>.*.checks.indentation.AbstractExpressionHandler</pattern><branchRate>91</branchRate><lineRate>97</lineRate></regex>
|
||||
<regex><pattern>.*.checks.indentation.LineWrappingHandler</pattern><branchRate>87</branchRate><lineRate>95</lineRate></regex>
|
||||
<regex><pattern>.*.checks.indentation.MethodCallLineWrapHandler</pattern><branchRate>0</branchRate><lineRate>0</lineRate></regex>
|
||||
<regex><pattern>.*.checks.indentation.ObjectBlockHandler</pattern><branchRate>75</branchRate><lineRate>100</lineRate></regex>
|
||||
<regex><pattern>.*.checks.indentation.SynchronizedHandler</pattern><branchRate>100</branchRate><lineRate>100</lineRate></regex>
|
||||
|
|
|
|||
|
|
@ -114,13 +114,6 @@ public class LineWrappingHandler {
|
|||
|| currentType == TokenTypes.ARRAY_INIT) {
|
||||
logWarningMessage(node, firstNodeIndent);
|
||||
}
|
||||
else if (currentType == TokenTypes.LITERAL_IF) {
|
||||
final DetailAST parent = node.getParent();
|
||||
|
||||
if (parent.getType() == TokenTypes.LITERAL_ELSE) {
|
||||
logWarningMessage(parent, currentIndent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
logWarningMessage(node, currentIndent);
|
||||
}
|
||||
|
|
@ -175,8 +168,7 @@ public class LineWrappingHandler {
|
|||
final DetailAST firstTokenOnLine = result.get(curNode.getLineNo());
|
||||
|
||||
if (firstTokenOnLine == null
|
||||
|| firstTokenOnLine != null
|
||||
&& firstTokenOnLine.getColumnNo() >= curNode.getColumnNo()) {
|
||||
|| firstTokenOnLine.getColumnNo() >= curNode.getColumnNo()) {
|
||||
result.put(curNode.getLineNo(), curNode);
|
||||
}
|
||||
curNode = getNextCurNode(curNode);
|
||||
|
|
@ -195,7 +187,7 @@ public class LineWrappingHandler {
|
|||
DetailAST nodeToVisit = curNode.getFirstChild();
|
||||
DetailAST currentNode = curNode;
|
||||
|
||||
while (currentNode != null && nodeToVisit == null) {
|
||||
while (nodeToVisit == null) {
|
||||
nodeToVisit = currentNode.getNextSibling();
|
||||
if (nodeToVisit == null) {
|
||||
currentNode = currentNode.getParent();
|
||||
|
|
@ -218,15 +210,13 @@ public class LineWrappingHandler {
|
|||
final Collection<DetailAST> values = firstNodesOnLines.values();
|
||||
final DetailAST lastAnnotationNode = getLastAnnotationNode(atNode);
|
||||
final int lastAnnotationLine = lastAnnotationNode.getLineNo();
|
||||
final int lastAnnotattionColumn = lastAnnotationNode.getColumnNo();
|
||||
|
||||
final Iterator<DetailAST> itr = values.iterator();
|
||||
while (itr.hasNext() && firstNodesOnLines.size() > 1) {
|
||||
while (firstNodesOnLines.size() > 1) {
|
||||
final DetailAST node = itr.next();
|
||||
|
||||
if (node.getLineNo() < lastAnnotationLine
|
||||
|| node.getLineNo() == lastAnnotationLine
|
||||
&& node.getColumnNo() <= lastAnnotattionColumn) {
|
||||
|| node.getLineNo() == lastAnnotationLine) {
|
||||
final DetailAST parentNode = node.getParent();
|
||||
if (node.getType() == TokenTypes.AT
|
||||
&& parentNode.getParent().getType() == TokenTypes.MODIFIERS) {
|
||||
|
|
|
|||
|
|
@ -112,6 +112,10 @@ public class InputValidArrayInitIndent { //indent:0 exp:0
|
|||
func1(new int[] { //indent:8 exp:8
|
||||
1, 2, 3 //indent:16 exp:16
|
||||
}); //indent:8 exp:8
|
||||
for (String veryLongVariableName: new String[] //indent:8 exp:8
|
||||
{"this is text", "this is text"}) { //indent:8 exp:8
|
||||
if (hashCode() == 0) break; //indent:12 exp:12
|
||||
} //indent:8 exp:8
|
||||
} //indent:4 exp:4
|
||||
|
||||
} //indent:0 exp:0
|
||||
|
|
|
|||
Loading…
Reference in New Issue