NotJavadoc Regression in 2.49.0
- 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
Assessment
This issue has not been assessed yet.