【发布时间】:2016-10-12 09:08:27
【问题描述】:
当if 条件很大并且占用多行时,条件和正文变成一个单块,因为默认缩进为 4,IDEA 将多行 if 对齐到 4。
if (status != HttpStatus.OK.value()
|| doc.title().equals("Foo")
|| list.isEmpty()) {
logger.info("Awful readability.");
foobar();
ex.execute(this);
}
或
if (status != HttpStatus.OK.value() ||
doc.title().equals("Foo") ||
list.isEmpty()) {
logger.info("The most horrible readability.");
foobar();
ex.execute(this);
}
可读性变得马马虎虎。为此,我想在条件之后插入一个空行,或者通过自动格式化为条件插入额外的缩进。
if (status != HttpStatus.OK.value()
|| doc.title().equals("Foo")
|| list.isEmpty()) {
logger.info("Good readability.");
foobar();
ex.execute(this);
}
OR
if (status != HttpStatus.OK.value()
|| doc.title().equals("Foo")
|| list.isEmpty()) {
logger.info("Good readability.");
foobar();
ex.execute(this);
}
很遗憾,我在代码样式选项中找不到任何内容。
【问题讨论】:
标签: intellij-idea coding-style