False Positive? initializer method does not guarantee @NonNull field
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 370
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 68
Description
maybe I'm doing something wrong, don't understand something, and the error message/documentation needs to be improved needs to be improved?
/Users/calebcushing/IdeaProjects/ppm/scaf/src/main/java/com/xenoterracide/scaf/SkeletonConfiguration.java:19: error: [NullAway] initializer method does not guarantee @NonNull field after (line 16) is initialized along all control-flow paths (remember to check for exceptions or early returns).
public SkeletonConfiguration(
^
(see http://t.uber.com/nullaway )
/* Copyright © 2020 Caleb Cushing. All rights reserved */
package com.xenoterracide.scaf;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Objects;
import java.util.regex.Pattern;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
class SkeletonConfiguration {
private final SourceType templateSourceType;
private final String source;
private final String destination;
private final Pattern after;
@JsonCreator
SkeletonConfiguration(
@NonNull String source,
@NonNull String destination,
@Nullable Pattern after,
@Nullable SourceType templateSourceType
) {
this.templateSourceType = templateSourceType == null ? SourceType.FILE : templateSourceType;
this.source = Objects.requireNonNull(source);
this.destination = Objects.requireNonNull(destination);
this.after = after;
}
public SourceType getTemplateSourceType() {
return templateSourceType;
}
public String getSource() {
return source;
}
public String getDestination() {
return destination;
}
public Pattern getAfter() {
return after;
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report using the shown SkeletonConfiguration.java example and the NullAway initializer diagnostic. Start by tracing the analysis of the constructor's final fields and nullable Pattern parameter. Done means determining whether this is a false positive and documenting or correcting the observed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100