Why it is matter ?
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html#s4.5.1-line-wrapping-where-to-break
"The prime directive of line-wrapping is: prefer to break at a higher syntactic level."
https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html#s4.5.2-line-wrapping-indent
"When there are multiple continuation lines, indentation may be varied beyond +4 as desired. In general, two continuation lines use the same indentation level if and only if they begin with syntactically parallel elements."
Cases from real code with bad indentation:
1)
if ((rcurly != null) && !level.accept(rcurlyPos)
&& (rcurlyMustStart() || startsLine(rcurly))
&& !areOnSameLine(rcurly, lcurly))
2)
details.append("Focused : ").append(file.getPath())
.append(", start date :")
.append(", end date : ");
3)
if (toVisitAst != null
&& (toVisitAst.getParent().getParent().getNextSibling() == null
|| toVisitAst.getParent().getParent().getNextSibling().getType()
== TokenTypes.RCURLY)
&& toVisitAst.getType() == TokenTypes.LITERAL_RETURN
&& toVisitAst.getParent().getNextSibling()== null) { }
===========================
resulted in https://github.com/checkstyle/checkstyle/issues/270
if (toVisitAst != null
&& (toVisitAst.getParent().getParent().getNextSibling() == null
|| toVisitAst.getParent().getParent().getNextSibling().getType()
== TokenTypes.RCURLY)
&& toVisitAst.getType() == TokenTypes.LITERAL_RETURN
&& toVisitAst.getParent().getNextSibling()== null) { }
===========================
resulted in https://github.com/checkstyle/checkstyle/issues/270
No comments:
Post a Comment