如何解决"At-clause should have a non-empty description?"错误? - Checkstyle - Java

13

我正在在Eclipse Luna中使用checkstyle插件的Google Java风格。 我在我的Java文档中反复看到这个错误,但似乎找不到解决方法。 这是一个小问题,但它让我感到烦恼。

我的Java文档:

/**
   * This is a description of something
   * 
   * @throws Exception
   */

错误位于@throws行,错误:

At-clause should have a non-empty description
3个回答

19

通常情况下,您应该写

 * @throws Exception when this exceptional condition happens

例如。

 * @throws IllegalArgumentException when num is negative

...并一般解释 为什么 会发生该异常。


2
这是文档中以“@”开头的参数的通用信息。因此,您需要为每个参数添加一些描述。
例如:
/**
     * Searches for top cars
     * @param carSearchRequest represents CarSearchRequest body
     * @param userId represents userid
     * @return CarsResponse
     * @throws Exception when userid is null
     */

0
为了快速解决这个问题,以免我的构建因checkstyle而失败,我创建了一个Eclipse 代码模板,用于“Javadoc”上下文中的使用:
${word_selection}
   *           When ${word_selection} occurs.

选择异常的名称,按下Ctrl+Space,选择“throws”(我给模板的名称),然后您就有了一个符合Checkstyle规范的注释:
* @throws IOException
*      When IOException occurs.

这是一个愚蠢的评论,但它也是一个愚蠢的要求。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接