如何修复超过80个字符的checkstyle错误?

时间:2017-12-02 05:10:39

标签: java checkstyle

  alert.setHeaderText(String.format(
                                     //this line//"Title:%s%nSinger:%s%nDate:%s%nAlbum:%s%nSongs:%s%nResult: %s",
                                      msg.getTitle(), msg.getSinger(),
                                      msg.getDate(), msg.getAlbum(),
                                      msg.getResult()));

我试图修复此检查样式错误。请帮忙!!!

1 个答案:

答案 0 :(得分:1)

为了解决这个checkstyle错误,您可以将此行拆分为两行,如下所示

alert.setHeaderText(String.format(
                                     "Title:%s%nSinger:%s%n" +
                                     "Date:%s%nAlbum:%s%nSongs:%s%nResult: %s",
                                      msg.getTitle(), msg.getSinger(),
                                      msg.getDate(), msg.getAlbum(),
                                      msg.getResult()));

你应该考虑缩进级别的公正和整体减少,例如......

alert.setHeaderText(String.format(
     "Title:%s%nSinger:%s%n" +
     "Date:%s%nAlbum:%s%nSongs:%s%nResult: %s",
     msg.getTitle(), msg.getSinger(),
     msg.getDate(), msg.getAlbum(),
     msg.getResult()));