Skip to content

Commit

Permalink
clean up fixIsSource flag from fix class
Browse files Browse the repository at this point in the history
  • Loading branch information
nimakarimipour committed Oct 3, 2024
1 parent 2a750e5 commit f44edb2
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ public void analyzeDownstreamDependencies() {
.map(
location ->
new Fix(
new AddMarkerAnnotation(location, context.config.nullableAnnot),
"null",
false))
new AddMarkerAnnotation(location, context.config.nullableAnnot), "null"))
.collect(ImmutableSet.toImmutableSet());
DownstreamImpactEvaluator evaluator = new DownstreamImpactEvaluator(supplier);
ImmutableSet<Report> reports = evaluator.evaluate(fixes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ private NullAwayError deserializeErrorFromTSVLine(ModuleInfo moduleInfo, String
Fix resolvingFix =
nonnullTarget == null
? null
: new Fix(
new AddMarkerAnnotation(nonnullTarget, config.nullableAnnot), errorType, true);
: new Fix(new AddMarkerAnnotation(nonnullTarget, config.nullableAnnot), errorType);
return createError(
errorType,
errorMessage,
Expand Down Expand Up @@ -201,8 +200,7 @@ protected ImmutableSet<Fix> generateFixesForUninitializedFields(
return new Fix(
new AddMarkerAnnotation(
extendVariableList(locationOnField, module), config.nullableAnnot),
NullAwayError.METHOD_INITIALIZER_ERROR,
true);
NullAwayError.METHOD_INITIALIZER_ERROR);
})
.filter(Objects::nonNull)
.collect(ImmutableSet.toImmutableSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ public void updateStatus(
public void mergeTriggered() {
this.tree.addAll(Error.getResolvingFixesOfErrors(this.triggeredErrors));
this.tree.addAll(triggeredFixesFromDownstreamErrors);
this.tree.forEach(fix -> fix.fixSourceIsInTarget = true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ protected Set<Fix> getTriggeredFixesFromDownstreamErrors(Node node) {
new Fix(
new AddMarkerAnnotation(
error.toResolvingLocation(), context.config.nullableAnnot),
"PASSING_NULLABLE",
false))
"PASSING_NULLABLE"))
.collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ public static <T extends Error> ImmutableSet<Fix> getResolvingFixesOfErrors(
for (Fix key : fixReasonsMap.keySet()) {
// To avoid mutating fixes stored in the given collection, we create new instances.
// which contain the full set of reasons.
builder.add(
new Fix(
key.change, ImmutableSet.copyOf(fixReasonsMap.get(key)), key.fixSourceIsInTarget));
builder.add(new Fix(key.change, ImmutableSet.copyOf(fixReasonsMap.get(key))));
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,13 @@ public class Fix {
/** Reasons this fix is suggested by NullAway in string. */
public final ImmutableSet<String> reasons;

/**
* If true, the fix is suggested due to an error in the target module, false if the fix is
* suggested due to error in downstream dependencies.
*/
public boolean fixSourceIsInTarget;

public Fix(AddAnnotation change, String reason, boolean fixSourceIsInTarget) {
this(change, ImmutableSet.of(reason), fixSourceIsInTarget);
public Fix(AddAnnotation change, String reason) {
this(change, ImmutableSet.of(reason));
}

public Fix(AddAnnotation change, ImmutableSet<String> reasons, boolean fixSourceIsInTarget) {
public Fix(AddAnnotation change, ImmutableSet<String> reasons) {
this.change = change;
this.reasons = reasons;
this.fixSourceIsInTarget = fixSourceIsInTarget;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ public ImmutableSet<Fix> extendForGeneratedFixes(Set<Fix> fixes) {
new Fix(
new AddMarkerAnnotation(
getterMethod.location, change.getAnnotationName().fullName),
fix.reasons,
fix.fixSourceIsInTarget));
fix.reasons));
}
})));
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
public class TFix extends Fix {

public TFix(Location location) {
super(new DefaultAnnotation(location), ImmutableSet.of(), true);
super(new DefaultAnnotation(location), ImmutableSet.of());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public TReport(Location root, int effect) {

public TReport(Location root, int effect, Tag tag) {
super(
new Fix(
new AddMarkerAnnotation(root, "javax.annotation.Nullable"), ImmutableSet.of(), true),
new Fix(new AddMarkerAnnotation(root, "javax.annotation.Nullable"), ImmutableSet.of()),
effect);
this.expectedValue = effect;
if (tag != null) {
Expand Down

0 comments on commit f44edb2

Please sign in to comment.