【问题标题】:How to fix Javadoc comment has parse error, Details: no viable alternative at input ' *' while parsing JAVADOC_TAG [NonEmptyAtClauseDescription]如何修复 Javadoc 注释有解析错误,详细信息:在解析 JAVADOC_TAG [NonEmptyAtClauseDescription] 时输入“*”没有可行的替代方案
【发布时间】:2021-12-11 23:18:07
【问题描述】:
/**
* This method is used for ABC.
* @return
* @throw IOException when this exceptional condition occurs
*/

[Error]:line:4- 第 0 列的 Javadoc 注释有解析错误。细节: 解析 JAVADOC_TAG 时输入“*”没有可行的替代方案 [NonEmptyAtClauseDescription]

知道为什么我在 Javadoc 的 @throw 行中收到此错误吗?如何解决这个问题?

【问题讨论】:

  • 因为您没有为方法返回的内容添加任何内容,并且它试图将 throw 行解析为返回的内容?

标签: java javadoc checkstyle summary maven-checkstyle-plugin


【解决方案1】:

如上所述,在返回标记中添加描述或将其完全删除以解决错误。

$ cat TestClass.java
public class TestClass {
    /**
    * This method is used for ABC.
    * @return desc
    * @throw IOException when this exceptional condition occurs
    */
    int method() throws IOException  {
        return 0; 
    }
}

$ cat TestConfig.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <property name="charset" value="UTF-8"/>

    <module name="TreeWalker">
        <module name="NonEmptyAtclauseDescriptionCheck" />
    </module>
</module>

$ java -jar checkstyle-9.0.1-all.jar -c TestConfig.xml TestClass.java
Starting audit...
Audit done.

【讨论】:

    猜你喜欢
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-13
    • 1970-01-01
    • 2018-03-28
    • 1970-01-01
    • 2016-01-14
    相关资源
    最近更新 更多