CheckStyle 注释

CheckStyle comments

在Idea中我转选项"Comment at first column"

CheckStyle 抛出错误 如何解决

 Comment has incorrect indentation level 0, expected is 10, indentation should be the same level as line 139. [CommentsIndentation]

编辑 2019 年 6 月 28 日

checkstyle.xml

想法偏好

如果块

148:            CompletableFuture.allOf(terminateEnvironmentResponseCompletableFuture, checkInvoicePaidResponseCompletableFuture,
149:                inactiveUserResponseCompletableFuture).whenComplete((v, th) -> {
151:              if (th != null) {
152:                log.error(th.getMessage(), th);
153:              }
154:              finishDelete(userDto);
155:            });

错误:

....java:150: 'if' has incorrect indentation level 14, expected level should be 18. [Indentation]
....java:151: 'if' child has incorrect indentation level 16, expected level should be 20. [Indentation]
....java:152: 'if rcurly' has incorrect indentation level 14, expected level should be 18. [Indentation]
....java:153: 'block' child has incorrect indentation level 14, expected level should be 18. [Indentation]
....java:154: 'block rcurly' has in*correct indentation level 12, expected level should be 16. [Indentation]

评论

108:          .withIdentity("ServicesTrigger", "TriggerGroup")
109://           is fired every day at 3:00 am
110:          .withSchedule(cronSchedule("0 0 3 * * ?"))
111://          .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(12).repeatForever())
112:          .forJob(_servicesJob)
113:          .build();
114:      _scheduler.scheduleJob(_servicesJob, serviceTrigger);

错误:

....java:110: Comment has incorrect indentation level 0, expected is 10, indentation should be the same level as line 111. [CommentsIndentation]
....java:112: Comment has incorrect indentation level 0, expected is 10, indentation should be the same level as line 113. [CommentsIndentation]

In Idea I turn options "Comment at first column"
CheckStyle throws an error How to solve it

CommentsIndentation 目前不支持在第一列中要求注释。默认行为是注释必须与周围代码的缩进相同。

如果您想从 CommentsIndentation 中看到这种行为,您需要在 github 上的 checkstyle 上创建一个问题。现在,我建议禁用检查。从配置中删除它或将其注释掉。

您可以将注释斜线“//”放在注释行文本的前面。这可以解决您的问题。

你的例子:

108:          .withIdentity("ServicesTrigger", "TriggerGroup")
109:          //is fired every day at 3:00 am
110:          .withSchedule(cronSchedule("0 0 3 * * ?"))
111:          //.withSchedule(SimpleScheduleBuilder. etc...