Skip to content

Commit

Permalink
Revert "Switch to Spotless for formatting Java code (uber#780)"
Browse files Browse the repository at this point in the history
This reverts commit 31004d3.
  • Loading branch information
msridhar committed Jul 18, 2023
1 parent e0a7ebe commit 24f0339
Show file tree
Hide file tree
Showing 23 changed files with 17 additions and 49 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ jobs:
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Build and test using Java ${{ matrix.java }} and Error Prone ${{ matrix.epVersion }}
- name: Build and test using Java 11 and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: gradle/gradle-build-action@v2
with:
arguments: verGJF build
if: matrix.java == '11'
- name: Build and test using Java 17 and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: gradle/gradle-build-action@v2
with:
arguments: build
if: matrix.java == '17'
- name: Report jacoco coverage
uses: gradle/gradle-build-action@v2
env:
Expand Down
22 changes: 6 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ buildscript {
}
}
plugins {
id "com.diffplug.spotless" version "6.19.0"
id "com.github.sherter.google-java-format" version "0.9"
id "net.ltgt.errorprone" version "3.0.1" apply false
id "com.github.johnrengelman.shadow" version "8.1.0" apply false
id "com.github.kt3k.coveralls" version "2.12.0" apply false
Expand Down Expand Up @@ -103,24 +103,14 @@ subprojects { project ->
google()
}

// For some reason, spotless complains when applied to the jar-infer folder itself, even
// though there is no top-level :jar-infer project
if (project.name != "jar-infer") {
project.apply plugin: "com.diffplug.spotless"
spotless {
java {
googleJavaFormat()
}
}
}
}

spotless {
predeclareDeps()
}
spotlessPredeclare {
java { googleJavaFormat('1.17.0') }
googleJavaFormat {
toolVersion = "1.14.0"
// don't enforce formatting for generated Java code under buildSrc
exclude 'buildSrc/build/**/*.java'
}

////////////////////////////////////////////////////////////////////////
//
// Google Java Format pre-commit hook installation
Expand Down
2 changes: 1 addition & 1 deletion config/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ REPO_ROOT_DIR="$(git rev-parse --show-toplevel)"
files=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.java$") || true)
if [ ! -z "${files}" ]; then
comma_files=$(echo "$files" | paste -s -d "," -)
"${REPO_ROOT_DIR}/gradlew" spotlessApply -Pspotless.ratchet.from=HEAD >/dev/null 2>&1
"${REPO_ROOT_DIR}/gradlew" goJF -DgoogleJavaFormat.include="$comma_files" &>/dev/null
git add $(echo "$files" | paste -s -d " " -)
fi
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ private static String getAstubxSignature(IMethod mtd) {
+ strArgTypes
+ ")";
}

/**
* Get simple unqualified type name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ final class ErrorProneCLIFlagsConfig extends AbstractConfig {
static final String FL_JI_REGEX_MODEL_PATH = EP_FL_NAMESPACE + ":JarInferRegexStripModelJar";
static final String FL_JI_REGEX_CODE_PATH = EP_FL_NAMESPACE + ":JarInferRegexStripCodeJar";
static final String FL_ERROR_URL = EP_FL_NAMESPACE + ":ErrorURL";

/** --- Serialization configs --- */
static final String FL_FIX_SERIALIZATION = EP_FL_NAMESPACE + ":SerializeFixMetadata";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ public interface LibraryModels {
final class MethodRef {

public final String enclosingClass;

/**
* we store the method name separately to enable fast comparison with MethodSymbols. See {@link
* com.uber.nullaway.handlers.LibraryModelsHandler.OptimizedLibraryModels}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ private static AccessPath fromVanillaMethodCall(
static AccessPath switchRoot(AccessPath origAP, Element newRoot) {
return new AccessPath(newRoot, origAP.elements, origAP.mapGetArg);
}

/**
* Construct the access path given a {@code base.element} structure.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class NullnessStore implements Store<NullnessStore> {
private NullnessStore(Map<AccessPath, Nullness> contents) {
this.contents = ImmutableMap.copyOf(contents);
}

/**
* Produce an empty store.
*
Expand Down Expand Up @@ -140,7 +139,6 @@ public AccessPath getMapGetIteratorContentsAccessPath(LocalVariableNode iterator
}
return null;
}

/**
* Gets the {@link Nullness} value of an access path.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class FixSerializationConfig {
* untouched.
*/
public final boolean suggestEnabled;

/**
* If enabled, serialized information of a fix suggest will also include the enclosing method and
* class of the element involved in error. Finding enclosing elements is costly and will only be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,10 @@
public class Serializer {
/** Path to write errors. */
private final Path errorOutputPath;

/** Path to write suggested fix metadata. */
private final Path suggestedFixesOutputPath;

/** Path to write suggested fix metadata. */
private final Path fieldInitializationOutputPath;

/**
* Adapter used to serialize outputs. This adapter is capable of serializing outputs according to
* the requested serilization version and maintaining backward compatibility with previous
Expand All @@ -69,7 +66,6 @@ public Serializer(FixSerializationConfig config, SerializationAdapter serializat
serializeVersion(outputDirectory);
initializeOutputFiles(config);
}

/**
* Appends the string representation of the {@link SuggestedNullableFixInfo}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ public abstract class AbstractSymbolLocation implements SymbolLocation {

/** Element kind of the targeted symbol */
protected final ElementKind type;

/** Path of the file containing the symbol, if available. */
@Nullable protected final Path path;

/** Enclosing class of the symbol. */
protected final Symbol.ClassSymbol enclosingClass;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ public class MethodParameterLocation extends AbstractSymbolLocation {

/** Symbol of the targeted method. */
private final Symbol.MethodSymbol enclosingMethod;

/** Symbol of the targeted method parameter. */
private final Symbol.VarSymbol paramSymbol;

/** Index of the method parameter in the containing method's argument list. */
private final int index;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class ErrorInfo {
* target, and this field is the Symbol for that target.
*/
@Nullable private final Symbol nonnullTarget;

/**
* In cases where {@link ErrorInfo#nonnullTarget} is {@code null}, we serialize this value at its
* placeholder in the output tsv file.
Expand All @@ -55,7 +54,6 @@ public class ErrorInfo {

/** Offset of program point where this error is reported. */
private final int offset;

/** Path to the containing source file where this error is reported. */
@Nullable private final Path path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public class FieldInitializationInfo {

/** Symbol of the initializer method. */
private final SymbolLocation initializerMethodLocation;

/** Symbol of the initialized class field. */
private final Symbol field;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class SuggestedNullableFixInfo {

/** SymbolLocation of the target element in source code. */
private final SymbolLocation symbolLocation;

/** Error which will be resolved by this type change. */
private final ErrorMessage errorMessage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
public abstract class AbstractFieldContractHandler extends BaseNoOpHandler {

protected static final String THIS_NOTATION = "this.";

/** Simple name of the annotation in {@code String} */
protected final String annotName;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.uber.nullaway.handlers;

/*
* Copyright (c) 2017 Uber Technologies, Inc.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.uber.nullaway.handlers.stream;

/*
* Copyright (c) 2017 Uber Technologies, Inc.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.uber.nullaway.handlers.stream;

/*
* Copyright (c) 2017 Uber Technologies, Inc.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.uber.nullaway.handlers.stream;

/*
* Copyright (c) 2017 Uber Technologies, Inc.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.uber.nullaway.handlers.stream;

/*
* Copyright (c) 2017 Uber Technologies, Inc.
*
Expand Down
6 changes: 0 additions & 6 deletions sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,3 @@ dependencies {
testImplementation deps.test.junit4

}

spotless {
java {
target 'src/*/java/**/*.java'
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include ':sample'
include ':test-java-lib'
include ':test-java-lib-lombok'
include ':test-library-models'
include ':compile-bench'
include ':jar-infer:android-jarinfer-models-sdk28'
include ':jar-infer:android-jarinfer-models-sdk29'
include ':jar-infer:android-jarinfer-models-sdk30'
Expand Down

0 comments on commit 24f0339

Please sign in to comment.