12

我在 eclipse luna 的 checkstyle 插件中使用 google java 样式。在我的 java 文档中看到这个错误,但似乎找不到解决方法。这是次要的,但它困扰着我。

我的javadoc:

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

错误在@throws 行,错误:

At-clause should have a non-empty description
4

3 回答 3

18

通常,您应该编写

 * @throws Exception when this exceptional condition happens

例如

 * @throws IllegalArgumentException when num is negative

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

于 2015-10-09T17:42:26.763 回答
2

这是 doc 中以“@”开头的每个参数显示的通用消息。因此,对于每个参数,您需要添加一些描述。

例如:

/**
     * Searches for top cars
     * @param carSearchRequest represents CarSearchRequest body
     * @param userId represents userid
     * @return CarsResponse
     * @throws Exception when userid is null
     */
于 2019-08-29T07:17:02.260 回答
0

为了快速处理这个问题,以便我的构建不会因 checkstyle 而失败,我制作了一个 Eclipse代码模板以在上下文“Javadoc”中使用:

${word_selection}
   *           When ${word_selection} occurs.

选择异常的名称,按 Ctrl+Space,选择“throws”(我给模板的名称),然后您就有了 Checkstyle-legal 注释:

* @throws IOException
*      When IOException occurs.

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

于 2020-02-05T18:39:56.820 回答