Search code examples
javajavadoccheckstylesummarymaven-checkstyle-plugin

How to fix Javadoc comment has parse error, Details: no viable alternative at input ' *' while parsing JAVADOC_TAG [NonEmptyAtClauseDescription]


/**
* This method is used for ABC.
* @return
* @throw IOException when this exceptional condition occurs
*/

[Error]:line:4- Javadoc comment at column 0 has parse error. Details: no viable alternative at input ' *' while parsing JAVADOC_TAG [NonEmptyAtClauseDescription]

Any idea why am I getting this error in the @throw line of Javadoc? How to fix this?


Solution

  • As described above, add a description to the return tag or remove it completely to resolve the error.

    $ 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.