yegor256
yegor256

Reputation: 105133

How to comment enum to make checkstyle happy?

This is the code:

/**
 * some text.
 */
public class Foo {
  /**
   * Some comment...
   */
  public enum Bar {
    /**
     * some text.
     */
    ABC,
    /**
     * some text.
     */
    CDE;
  };
}

Checkstyle says Missing a Javadoc comment. twice (line with ABC and line with CDE). What is it about? Where should I add comment? JavaDoc works just fine.

Upvotes: 2

Views: 7008

Answers (3)

yegor256
yegor256

Reputation: 105133

The magic static solves the problem:

/**
 * some text.
 */
public class Foo {
  /**
   * Some comment...
   */
  public static enum Bar {
    /**
     ...

Upvotes: 5

atk
atk

Reputation: 9324

(copying my comment into an answer, since that seems to be the current solution, and it'll hopefully help get this question marked closed)

this may be a bug in checkstyle. either the error mesage is incorrect (since javadoc works just fine) or it's unclear (like if the comment is missing an @author or something).

Upvotes: 0

Peter Lawrey
Peter Lawrey

Reputation: 533660

Comments start with /* and Javadocs start with /**. If you use a the latter, checkstyle will warn you that some Javadoc details are missing. If you intended to have just a comment, use /* at the start of your comment.

/*
 * some text.
 */
public class Foo {
  /*
   * Some comment...
   */
  public enum Bar {
    /*
     * some text.
     */
    ABC,
    /*
     * some text.
     */
    CDE
  }
}

Upvotes: 0

Related Questions