Skip to content

Commit

Permalink
Bit of a diminishing-returns refactoring, but...
Browse files Browse the repository at this point in the history
  • Loading branch information
lazaroclapp committed May 13, 2022
1 parent 2b4970b commit 7df44b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
20 changes: 7 additions & 13 deletions nullaway/src/main/java/com/uber/nullaway/AbstractConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,26 +291,20 @@ public boolean isContractAnnotation(String annotationName) {
return contractAnnotations.contains(annotationName);
}

protected ImmutableSet<MethodClassAndName> getKnownInitializers(
ImmutableSet<String> qualifiedNames) {
return qualifiedNames.stream()
.map(
name -> {
int lastDot = name.lastIndexOf('.');
String methodName = name.substring(lastDot + 1);
String className = name.substring(0, lastDot);
return MethodClassAndName.create(className, methodName);
})
.collect(ImmutableSet.toImmutableSet());
}

@AutoValue
abstract static class MethodClassAndName {

static MethodClassAndName create(String enclosingClass, String methodName) {
return new AutoValue_AbstractConfig_MethodClassAndName(enclosingClass, methodName);
}

static MethodClassAndName fromClassDotMethod(String classDotMethod) {
int lastDot = classDotMethod.lastIndexOf('.');
String methodName = classDotMethod.substring(lastDot + 1);
String className = classDotMethod.substring(0, lastDot);
return MethodClassAndName.create(className, methodName);
}

abstract String enclosingClass();

abstract String methodName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,9 @@ final class ErrorProneCLIFlagsConfig extends AbstractConfig {
sourceClassesToExclude = getFlagStringSet(flags, FL_CLASSES_TO_EXCLUDE);
unannotatedClasses = getFlagStringSet(flags, FL_UNANNOTATED_CLASSES);
knownInitializers =
getKnownInitializers(
getFlagStringSet(flags, FL_KNOWN_INITIALIZERS, DEFAULT_KNOWN_INITIALIZERS));
getFlagStringSet(flags, FL_KNOWN_INITIALIZERS, DEFAULT_KNOWN_INITIALIZERS).stream()
.map(MethodClassAndName::fromClassDotMethod)
.collect(ImmutableSet.toImmutableSet());
excludedClassAnnotations =
getFlagStringSet(
flags, FL_CLASS_ANNOTATIONS_TO_EXCLUDE, DEFAULT_CLASS_ANNOTATIONS_TO_EXCLUDE);
Expand Down

0 comments on commit 7df44b4

Please sign in to comment.