How to resolve At-clause should have a non-empty description? - Checkstyle - Java
Asked Answered
D

3

14

I am using the google java style in the checkstyle plugin for eclipse luna. Seeing this error all over my java doc but cannot seem to find how to resolve it. It's minor but its bugging me.

my javadoc:

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

Error is on the @throws line, Error:

At-clause should have a non-empty description
Decadence answered 9/10, 2015 at 17:41 Comment(0)
A
21

Typically, you should write

 * @throws Exception when this exceptional condition happens

e.g.

 * @throws IllegalArgumentException when num is negative

...and generally explaining why that exception would occur.

Attwood answered 9/10, 2015 at 17:42 Comment(0)
B
2

This is the generic message shown for every parameters in doc starting with '@'. So for every param you need to add some description.

For example:

/**
     * Searches for top cars
     * @param carSearchRequest represents CarSearchRequest body
     * @param userId represents userid
     * @return CarsResponse
     * @throws Exception when userid is null
     */
Bellicose answered 29/8, 2019 at 7:17 Comment(0)
T
0

To deal with this fast so my build doesn't fail from checkstyle, I made an Eclipse code template to use in the context "Javadoc":

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

Select the name of the exception, hit Ctrl+Space, choose "throws" (the name I gave the template), and you have a Checkstyle-legal comment:

* @throws IOException
*      When IOException occurs.

It's a dumb comment, but it's a dumb requirement too.

Tiberias answered 5/2, 2020 at 18:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.