google / google/error-prone

NotJavadoc Regression in 2.49.0

Open
#5,739 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

NotJavadoc in 2.49.0 refuses javadoc on statics in enum constants.

## Example

```java
package org.example;

/** Enum. */
@SuppressWarnings("unused")
public enum MyEnum {

/** Value. */
VALUE {

/** Static variable. */
static final int STATIC_1 = 1;
}
}
```

This code is allowed in 2.48.0, but is rejected in 2.49.0 with the following message:

```
[NotJavadoc] Avoid using `/**` for comments which aren't actually Javadoc.
(see https://errorprone.info/bugpattern/NotJavadoc)
Did you mean '/* Static variable. */'?
```

Note that making the static variable `public` does not resolve the issue (it just results in a new `EffectivelyPrivate` error.)

## Workaround

Static can be moved out of enum constant scope, if name is kept unique within the enum:

```java
package org.example;

/** Enum. */
@SuppressWarnings("unused")
public enum MyEnum {

/** Value. */
VALUE {};

/** Static variable. */
static final int STATIC_1 = 1;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.