Skip to content

Commit ffa9b7f

Browse files
committed
Make UnusedVariable an error
ExecutableTransform's logger, StringWrapper's endLine and the stderr two MainTest tests read after the process had exited were never read. They are gone, and Error Prone now fails the build on the next one.
1 parent 2edd7d9 commit ffa9b7f

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎buildSrc/src/main/groovy/open-java-format.error-prone-conventions.gradle‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,10 @@ tasks.withType(JavaCompile).configureEach {
5151
//disable('NonStaticImport')
5252
}
5353
}
54+
55+
// Checks whose findings have been fixed, build-breaking so that new ones are fixed too rather than read past.
56+
tasks.withType(JavaCompile).configureEach {
57+
options.errorprone {
58+
error('UnusedVariable')
59+
}
60+
}

‎gradle-open-java-format/src/main/java/com/palantir/javaformat/gradle/ExecutableTransform.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import org.gradle.api.artifacts.transform.TransformOutputs;
3232
import org.gradle.api.artifacts.transform.TransformParameters;
3333
import org.gradle.api.file.FileSystemLocation;
34-
import org.gradle.api.logging.Logger;
35-
import org.gradle.api.logging.Logging;
3634
import org.gradle.api.provider.Provider;
3735
import org.gradle.api.tasks.PathSensitive;
3836
import org.gradle.api.tasks.PathSensitivity;
@@ -47,8 +45,6 @@
4745
because = "Only copies one file and sets its executable bit; caching would cost more than it saves")
4846
public abstract class ExecutableTransform implements TransformAction<TransformParameters.None> {
4947

50-
private static Logger logger = Logging.getLogger(ExecutableTransform.class);
51-
5248
@InputArtifact
5349
@PathSensitive(PathSensitivity.NAME_ONLY)
5450
public abstract Provider<FileSystemLocation> getInputArtifact();

‎open-java-format/src/main/java/com/palantir/javaformat/java/StringWrapper.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,6 @@ private String computePrefixIndentation(
448448
int startLine = lineMap.getLineNumber(startingPos);
449449
int lineStartPosition = lineMap.getStartPosition(startLine);
450450
int endPos = getEndPosition(unit, expression);
451-
int endLine = lineMap.getLineNumber(endPos);
452451
int parentLine = shouldUseStartLineParent ? startParentLine : endParentLine;
453452
// ignore indentation if the current argument is on the same line as the parent
454453
if (startLine == parentLine) {

‎open-java-format/src/test/java/com/palantir/javaformat/java/MainTest.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ void exitIfChangedStdin() throws Exception {
483483
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
484484
Process process = formatterMain("-").redirectInput(path.toFile()).start();
485485
process.waitFor();
486-
String err = new String(ByteStreams.toByteArray(process.getErrorStream()), UTF_8);
487486
String out = new String(ByteStreams.toByteArray(process.getInputStream()), UTF_8);
488487
assertThat(out).isEqualTo("<stdin>" + System.lineSeparator());
489488
assertThat(process.exitValue()).isEqualTo(1);
@@ -495,7 +494,6 @@ void exitIfChangedFiles() throws Exception {
495494
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
496495
Process process = formatterMain(path.toAbsolutePath().toString()).start();
497496
process.waitFor();
498-
String err = new String(ByteStreams.toByteArray(process.getErrorStream()), UTF_8);
499497
String out = new String(ByteStreams.toByteArray(process.getInputStream()), UTF_8);
500498
assertThat(out).isEqualTo(path.toAbsolutePath().toString() + System.lineSeparator());
501499
assertThat(process.exitValue()).isEqualTo(1);

0 commit comments

Comments
 (0)