Checkstyle "Expected @param tag for id error

I am using the checkout style in my codebase, http://checkstyle.sourceforge.net/ , and I have a question regarding JAVADOC.

I have static functions like this:

** * @param id */ public static void getName(final String id) { } 

where checkstyle complains

Expected @param tag for 'id'

When I give a description of how

 @param id id 

then everything works fine, but I do not want to give a description for each parameter and return. Is there an alternative to fix this?

+6
source share
3 answers

You are right - this warning means that you do not have a description of the parameter. If you do not want to describe a parameter, why not mention it? Your current JavaDoc is meaningless and occupies only invaluable editor space.

Either completely remove the parameter from the JavaDoc (I assume this value is obvious from the context), or document it correctly. AND

 /** * id The id */ 

not proper documentation.

+13
source

Why run a control style if you are going to ignore it?

I pretty much agree with @Tomasz Nurkiewicz's answer, except that I will definitely document it.

The value of final String id may be obvious. You. Now. The getName method getName also be obvious - for now.

When I look at him, I have no idea what he is doing or what kind of "identifier" I need to convey. Does it get the full legal username? What name did they enter? Their [last name, first name]? What type of id String do I need to pass? Internal ID / Application Code? You have no javadoc for what the method itself does.

 /** * Gets the indicated user full name as entered when they registered. * @param id The application internal id generated when the user registered. * @return "void" ??? How do you get a name if it returns VOID? */ public static void getName(final String id) { ... } 

I would declare this as a public static String getName(...) because how can you get a name if it returns nothing? If it does something else, for example, put the name somewhere, you can get it later, then (1) it should not be called "getName", and (2) you definitely need to document this fact in your javadoc.

+3
source

You can fix this by changing your comment.

 /** * this is comment of function * @param id **this is id of table** * @param username **this is name of user need for login** */ 

Please focus on ** {text} ** to fix this error. thanks

0
source

Source: https://habr.com/ru/post/1398280/


All Articles