-
Notifications
You must be signed in to change notification settings - Fork 782
Open
Description
Description of the problem / feature request:
VarChecker seems to behave erratically on implemented classes (and some other cases I haven't been able to fully pin down).
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
public class HealthCheckManager implements io.dropwizard.lifecycle.Managed {
private final HealthCheckRegistry registry;
private final ImmutableMap<String, HealthCheck> checks;
@Inject
HealthCheckManager(HealthCheckRegistry registry, Map<String, HealthCheck> checks) {
this.registry = registry;
this.checks = ImmutableMap.copyOf(checks);
}
@Override
public void start() {
checks.forEach(registry::register);
}
@Override
public void stop() {}
}
Generates the following:
<path>/HealthCheckManager.java:20: error: [Var] Non-constant variable missing @Var annotation
HealthCheckManager(HealthCheckRegistry registry, Map<String, HealthCheck> checks) {
^
(see https://errorprone.info/bugpattern/Var)
Did you mean 'HealthCheckManager(@Var HealthCheckRegistry registry, Map<String, HealthCheck> checks) {'?
<path>/HealthCheckManager.java:20: error: [Var] Non-constant variable missing @Var annotation
HealthCheckManager(HealthCheckRegistry registry, Map<String, HealthCheck> checks) {
^
(see https://errorprone.info/bugpattern/Var)
Did you mean 'HealthCheckManager(HealthCheckRegistry registry, @Var Map<String, HealthCheck> checks) {'?
Emphasizing the state doesn't fix it, if I mark the two parameters in question final it compiles normally, but I get the following:
HealthCheckManager(final HealthCheckRegistry registry, final Map<String, HealthCheck> checks) {
^
(see https://errorprone.info/bugpattern/Var)
Did you mean 'HealthCheckManager(HealthCheckRegistry registry, final Map<String, HealthCheck> checks) {'?
<path>/HealthCheckManager.java:20: error: [Var] Unnecessary 'final' modifier.
HealthCheckManager(final HealthCheckRegistry registry, final Map<String, HealthCheck> checks) {
^
(see https://errorprone.info/bugpattern/Var)
Did you mean 'HealthCheckManager(final HealthCheckRegistry registry, Map<String, HealthCheck> checks) {'?
Annotating them with @Var prevents the alert, but is inaccurate. Changing the names of the variables doesn't seem to help.
What version of Error Prone are you using?
2.3.2
openjdk 11 2018-09-25
OpenJDK Runtime Environment AdoptOpenJDK (build 11+28)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11+28, mixed mode)```
### Have you found anything relevant by searching the web?
Could not find it in the github issues nor in `error-prone-discuss`.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels