akb*_*ram 5 java checkstyle maven
我们的项目包含链接流畅风格的方法中的许多语句:
int totalCount = ((Number) em
.createQuery("select count(up) from UserPermission up where " +
"up.database.id = :dbId and " +
"up.user.id <> :currentUserId ")
.setParameter("dbId", cmd.getDatabaseId())
.setParameter("currentUserId", currentUser.getId())
.getSingleResult())
.intValue();
Run Code Online (Sandbox Code Playgroud)
我的checkstyle主要配置为匹配我们现有的代码样式,但现在它在这些代码片段上失败了,而是更喜欢:
int totalCount = ((Number) em
.createQuery("select count(up) from UserPermission up where " +
"up.database.id = :dbId and " +
"up.user.id <> :currentUserId ")
.setParameter("dbId", cmd.getDatabaseId())
.setParameter("currentUserId", currentUser.getId())
.getSingleResult())
.intValue();
Run Code Online (Sandbox Code Playgroud)
这完全不合适.反正配置checkstyle是否接受方法链接样式?是否有一个替代工具我可以从maven运行来强制执行这种缩进?
Mar*_*ten -2
我从来没有在 Eclipse 中完成这项工作,所以我们几乎不使用 Format Source。最后,延长期限往往是最好的选择。我们努力尝试但失败了。那是一年半前的事了。最后,我们仅在 Eclipse 中通过选择行或在手动格式化之前预格式化来使用格式化文本。
通常工程师所做的格式化具有一定的意义。所以自动格式化永远不会起作用。特别是如果你做了类似的事情
public static void myMethod(
int value, String value2, String value3)
如果您自动格式化它,它会失败,与您的示例类似。
因此,请随意加入不使用自动格式化的俱乐部,作为以人为方式格式化之前的一个步骤。