diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ThrowSpecificity.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ThrowSpecificity.java index a640e3725..1d3c5654d 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ThrowSpecificity.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ThrowSpecificity.java @@ -44,16 +44,17 @@ link = "https://github.com/palantir/gradle-baseline#baseline-error-prone-checks", linkType = BugPattern.LinkType.CUSTOM, severity = BugPattern.SeverityLevel.SUGGESTION, - summary = "Prefer to declare more specific throws types than Exception and Throwable. When methods are " - + "updated to throw new checked exceptions they expect callers to handle failure types explicitly. " - + "Throwing broad types defeats the type system. By throwing the most specific types possible we " - + "leverage existing compiler functionality to detect unreachable code.\n" - + "Note: Checked exceptions are only validated by the compiler and can be thrown by non-standard " - + "bytecode at runtime, for example when java code calls into groovy or scala generated bytecode " - + "a checked exception can be thrown despite not being declared. In these scenarios we recommend " - + "suppressing this check using @SuppressWarnings(\"ThrowSpecificity\") and a comment describing " - + "the reason. Remaining instances can be automatically fixed using " - + "./gradlew compileJava -PerrorProneApply=ThrowSpecificity") + summary = + "Prefer to declare more specific throws types than Exception and Throwable. When methods are updated" + + " to throw new checked exceptions they expect callers to handle failure types explicitly." + + " Throwing broad types defeats the type system. By throwing the most specific types possible we" + + " leverage existing compiler functionality to detect unreachable code.\n" + + "Note: Checked exceptions are only validated by the compiler and can be thrown by non-standard" + + " bytecode at runtime, for example when java code calls into groovy or scala generated bytecode" + + " a checked exception can be thrown despite not being declared. In these scenarios we recommend" + + " suppressing this check using @SuppressWarnings(\"ThrowSpecificity\") and a comment describing" + + " the reason. Remaining instances can be automatically fixed using ./gradlew compileJava" + + " -PerrorProneApply=ThrowSpecificity") public final class ThrowSpecificity extends BugChecker implements BugChecker.MethodTreeMatcher { // Maximum of three checked exception types to avoid unreadable long catch statements. @@ -95,9 +96,12 @@ public Description matchMethod(MethodTree tree, VisitorState state) { } SuggestedFix.Builder fix = SuggestedFix.builder(); return buildDescription(throwsExpression) - .addFix(fix.replace(throwsExpression, checkedExceptions.stream() - .map(checkedException -> MoreSuggestedFixes.prettyType(state, fix, checkedException)) - .collect(Collectors.joining(", "))) + .addFix(fix.replace( + throwsExpression, + checkedExceptions.stream() + .map(checkedException -> + MoreSuggestedFixes.prettyType(state, fix, checkedException)) + .collect(Collectors.joining(", "))) .build()) .build(); } @@ -116,8 +120,8 @@ private static boolean safeToModifyThrowsClause(MethodTree tree) { // Don't suggest modifying public API && !methodModifiers.contains(Modifier.PUBLIC) && (symbol.isStatic() - || methodModifiers.contains(Modifier.FINAL) - || ASTHelpers.enclosingClass(symbol).getModifiers().contains(Modifier.FINAL)); + || methodModifiers.contains(Modifier.FINAL) + || ASTHelpers.enclosingClass(symbol).getModifiers().contains(Modifier.FINAL)); } private static boolean containsBroadException(Collection exceptions, VisitorState state) { diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ValidateConstantMessage.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ValidateConstantMessage.java index ff601b3ce..8a47e4d83 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ValidateConstantMessage.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/ValidateConstantMessage.java @@ -42,9 +42,8 @@ public final class ValidateConstantMessage extends BugChecker implements BugChec private static final long serialVersionUID = 1L; - private static final Matcher VALIDATE_METHODS = - MethodMatchers.staticMethod() - .onClassAny("org.apache.commons.lang3.Validate", "org.apache.commons.lang.Validate"); + private static final Matcher VALIDATE_METHODS = MethodMatchers.staticMethod() + .onClassAny("org.apache.commons.lang3.Validate", "org.apache.commons.lang.Validate"); private final Matcher compileTimeConstExpressionMatcher = new CompileTimeConstantExpressionMatcher(); @@ -88,9 +87,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState ExpressionTree messageArg = args.get(messageArgNumber - 1); boolean isStringType = ASTHelpers.isSameType( - ASTHelpers.getType(messageArg), - state.getTypeFromString("java.lang.String"), - state); + ASTHelpers.getType(messageArg), state.getTypeFromString("java.lang.String"), state); boolean isConstantString = compileTimeConstExpressionMatcher.matches(messageArg, state); if (!isStringType || isConstantString) { return Description.NO_MATCH; @@ -100,7 +97,8 @@ public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState return Description.NO_MATCH; } - return buildDescription(tree).setMessage( - "Validate.X() statement uses a non-constant message").build(); + return buildDescription(tree) + .setMessage("Validate.X() statement uses a non-constant message") + .build(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/BracesRequiredTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/BracesRequiredTest.java index 9391d5497..71d020b47 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/BracesRequiredTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/BracesRequiredTest.java @@ -23,14 +23,15 @@ public class BracesRequiredTest { @Test void testFix_if_then() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) System.out.println();", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) {", @@ -43,8 +44,8 @@ void testFix_if_then() { @Test void testFix_if_else() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) {", @@ -53,7 +54,8 @@ void testFix_if_else() { " System.out.println(\"else\");", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) {", @@ -68,8 +70,8 @@ void testFix_if_else() { @Test void testFix_if_both() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param)", @@ -78,7 +80,8 @@ void testFix_if_both() { " System.out.println(\"else\");", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) {", @@ -93,15 +96,16 @@ void testFix_if_both() { @Test void testFix_if_emptyThen() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param); else", " System.out.println(\"else\");", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param); else {", @@ -114,14 +118,15 @@ void testFix_if_emptyThen() { @Test void testFix_while() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " while (param) System.out.println();", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " while (param) {", @@ -134,14 +139,15 @@ void testFix_while() { @Test void testFix_doWhile() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " do System.out.println(); while (param);", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " do {", @@ -154,14 +160,15 @@ void testFix_doWhile() { @Test void testFix_for() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " for (int i = 0; i < 5; i++) System.out.println();", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " for (int i = 0; i < 5; i++) {", @@ -174,15 +181,16 @@ void testFix_for() { @Test void testFix_enhancedFor() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.util.List;", "class Test {", " void f(List list) {", " for (String item : list) System.out.println(item);", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.util.List;", "class Test {", " void f(List list) {", @@ -196,8 +204,8 @@ void testFix_enhancedFor() { @Test void testFix_nested() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) if (param) {", @@ -205,7 +213,8 @@ void testFix_nested() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean param) {", " if (param) {", @@ -220,15 +229,16 @@ void testFix_nested() { @Test void testFix_elseIf() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(boolean p0, boolean p1) {", " if (p0) System.out.println();", " else if (p1) System.out.println();", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(boolean p0, boolean p1) {", " if (p0) {", diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchBlockLogExceptionTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchBlockLogExceptionTest.java index 4862c63c2..68b6b561d 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchBlockLogExceptionTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchBlockLogExceptionTest.java @@ -27,8 +27,8 @@ @Execution(ExecutionMode.CONCURRENT) public class CatchBlockLogExceptionTest { - private static final String errorMsg = "BUG: Diagnostic contains: " - + "Catch block contains log statements but thrown exception is never logged"; + private static final String errorMsg = + "BUG: Diagnostic contains: " + "Catch block contains log statements but thrown exception is never logged"; private CompilationTestHelper compilationHelper; @@ -74,8 +74,8 @@ public void testNoLogStatement() { @Test public void testFix_simple() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;", "class Test {", @@ -88,7 +88,8 @@ public void testFix_simple() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;", "class Test {", @@ -107,8 +108,8 @@ public void testFix_simple() { @Test public void testFix_ambiguous() { // In this case there are multiple options, no fixes should be suggested. - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;", "class Test {", @@ -122,7 +123,8 @@ public void testFix_ambiguous() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;", "class Test {", @@ -142,8 +144,8 @@ public void testFix_ambiguous() { @Test public void testFix_getMessage() { // In this case there are multiple options, no fixes should be suggested. - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;", "class Test {", @@ -156,7 +158,8 @@ public void testFix_getMessage() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import org.slf4j.Logger;", "import org.slf4j.LoggerFactory;", "class Test {", diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchSpecificityTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchSpecificityTest.java index 818909705..422da6091 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchSpecificityTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/CatchSpecificityTest.java @@ -23,8 +23,8 @@ class CatchSpecificityTest { @Test void testFix_simple() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -34,7 +34,8 @@ void testFix_simple() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -49,8 +50,8 @@ void testFix_simple() { @Test void testFixMultipleCatchBlocks() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -62,7 +63,8 @@ void testFixMultipleCatchBlocks() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -79,8 +81,8 @@ void testFixMultipleCatchBlocks() { @Test void testFixMultipleCatchBlocks_unnecessaryCatch() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -92,7 +94,8 @@ void testFixMultipleCatchBlocks_unnecessaryCatch() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -107,8 +110,8 @@ void testFixMultipleCatchBlocks_unnecessaryCatch() { @Test void testFixMultipleCatchBlocks_unnecessaryCatch_finally() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -122,7 +125,8 @@ void testFixMultipleCatchBlocks_unnecessaryCatch_finally() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -139,8 +143,8 @@ void testFixMultipleCatchBlocks_unnecessaryCatch_finally() { @Test void testFix_resourceDoesNotThrow() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -155,7 +159,8 @@ void testFix_resourceDoesNotThrow() { " @Override public void close() {}", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -175,8 +180,8 @@ void testFix_resourceDoesNotThrow() { @Test void testFix_resourceThrowsUnchecked() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -191,7 +196,8 @@ void testFix_resourceThrowsUnchecked() { " @Override public void close() throws RuntimeException {}", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -211,8 +217,8 @@ void testFix_resourceThrowsUnchecked() { @Test void testFixWithUnreachableConditional() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -226,7 +232,8 @@ void testFixWithUnreachableConditional() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -241,8 +248,8 @@ void testFixWithUnreachableConditional() { @Test void testFixWithImpossibleInstanceOf() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " boolean f(String param) {", " try {", @@ -254,7 +261,8 @@ void testFixWithImpossibleInstanceOf() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " boolean f(String param) {", " try {", @@ -270,8 +278,8 @@ void testFixWithImpossibleInstanceOf() { @Test void testFixWithUnreachableConditional_else() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -287,7 +295,8 @@ void testFixWithUnreachableConditional_else() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f(String param) {", " try {", @@ -303,8 +312,8 @@ void testFixWithUnreachableConditional_else() { @Test void testResource_creationThrows() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -315,7 +324,8 @@ void testResource_creationThrows() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -329,11 +339,10 @@ void testResource_creationThrows() { .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); } - @Test void testResource_closeThrows() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -347,7 +356,8 @@ void testResource_closeThrows() { " return new ByteArrayOutputStream();", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -366,8 +376,8 @@ void testResource_closeThrows() { @Test void testCheckedException() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -378,7 +388,8 @@ void testCheckedException() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -394,8 +405,8 @@ void testCheckedException() { @Test void test_testCodeNotModified() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import static org.assertj.core.api.Assertions.assertThat;", "class Test {", " void f(String param) {", @@ -412,8 +423,8 @@ void test_testCodeNotModified() { @Test void testCatchesExceptionAndThrowable() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -426,7 +437,8 @@ void testCatchesExceptionAndThrowable() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -444,8 +456,8 @@ void testCatchesExceptionAndThrowable() { @Test void fixAnonymousException() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -456,7 +468,8 @@ void fixAnonymousException() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(String param) {", @@ -472,8 +485,8 @@ void fixAnonymousException() { @Test void typeParameterException() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(ThrowingRunnable in) {", " try {", @@ -492,8 +505,8 @@ void typeParameterException() { @Test void exceptionAssignment_singleType() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f() throws Exception {", " try {", @@ -504,7 +517,8 @@ void exceptionAssignment_singleType() { " }", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "class Test {", " void f() throws Exception {", " try {", @@ -520,8 +534,8 @@ void exceptionAssignment_singleType() { @Test void exceptionAssignment_unionType() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f() throws Throwable {", " try {", @@ -540,8 +554,8 @@ void exceptionAssignment_unionType() { @Test void typeParameterExceptionToRuntimeException() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "class Test {", " void f(ThrowingRunnable in) {", " try {", @@ -560,8 +574,8 @@ void typeParameterExceptionToRuntimeException() { @Test void typeParameterIoException() { - fix() - .addInputLines("Test.java", + fix().addInputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(ThrowingRunnable in) {", @@ -575,7 +589,8 @@ void typeParameterIoException() { " void run() throws T;", " }", "}") - .addOutputLines("Test.java", + .addOutputLines( + "Test.java", "import java.io.*;", "class Test {", " void f(ThrowingRunnable in) {", diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousCompletableFutureUsageTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousCompletableFutureUsageTest.java index 2e06f57f5..83e2939d4 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousCompletableFutureUsageTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousCompletableFutureUsageTest.java @@ -32,118 +32,131 @@ public void before() { @Test public void should_fail_without_executor_supplyAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "class Test {", - " public static final void main(String[] args) {", - " // BUG: Diagnostic contains: Should not use CompletableFuture methods without specifying", - " CompletableFuture.supplyAsync(() -> 1L);", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "class Test {", + " public static final void main(String[] args) {", + " // BUG: Diagnostic contains: Should not use CompletableFuture methods without" + + " specifying", + " CompletableFuture.supplyAsync(() -> 1L);", + " }", + "}") + .doTest(); } @Test public void should_pass_with_executor_supplyAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "import java.util.concurrent.Executors;", - "class Test {", - " public static final void main(String[] args) {", - " CompletableFuture.supplyAsync(() -> 1L, Executors.newCachedThreadPool());", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "import java.util.concurrent.Executors;", + "class Test {", + " public static final void main(String[] args) {", + " CompletableFuture.supplyAsync(() -> 1L, Executors.newCachedThreadPool());", + " }", + "}") + .doTest(); } @Test public void should_fail_without_executor_runAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "class Test {", - " public static final void main(String[] args) {", - " // BUG: Diagnostic contains: Should not use CompletableFuture methods without specifying", - " CompletableFuture.runAsync(() -> {});", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "class Test {", + " public static final void main(String[] args) {", + " // BUG: Diagnostic contains: Should not use CompletableFuture methods without" + + " specifying", + " CompletableFuture.runAsync(() -> {});", + " }", + "}") + .doTest(); } @Test public void should_pass_with_executor_runAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "import java.util.concurrent.Executors;", - "class Test {", - " public static final void main(String[] args) {", - " CompletableFuture.runAsync(() -> {}, Executors.newCachedThreadPool());", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "import java.util.concurrent.Executors;", + "class Test {", + " public static final void main(String[] args) {", + " CompletableFuture.runAsync(() -> {}, Executors.newCachedThreadPool());", + " }", + "}") + .doTest(); } @Test public void should_fail_without_executor_thenApplyAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "class Test {", - " public static final void main(String[] args) {", - " CompletableFuture future = CompletableFuture.completedFuture(1);", - " // BUG: Diagnostic contains: Should not use CompletableFuture methods without specifying", - " future.thenApplyAsync(i -> i);", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "class Test {", + " public static final void main(String[] args) {", + " CompletableFuture future = CompletableFuture.completedFuture(1);", + " // BUG: Diagnostic contains: Should not use CompletableFuture methods without" + + " specifying", + " future.thenApplyAsync(i -> i);", + " }", + "}") + .doTest(); } @Test public void should_pass_with_executor_thenApplyAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "import java.util.concurrent.Executors;", - "class Test {", - " public static final void main(String[] args) {", - " CompletableFuture.completedFuture(1).thenApplyAsync(i -> i, Executors.newCachedThreadPool());", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "import java.util.concurrent.Executors;", + "class Test {", + " public static final void main(String[] args) {", + " CompletableFuture.completedFuture(1).thenApplyAsync(i -> i," + + " Executors.newCachedThreadPool());", + " }", + "}") + .doTest(); } @Test public void should_fail_without_executor_applyToEitherAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "class Test {", - " public static final void main(String[] args) {", - " CompletableFuture futureOne = CompletableFuture.completedFuture(1);", - " CompletableFuture futureTwo = CompletableFuture.completedFuture(2);", - " // BUG: Diagnostic contains: Should not use CompletableFuture methods without specifying", - " futureOne.applyToEitherAsync(futureTwo, i -> i);", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "class Test {", + " public static final void main(String[] args) {", + " CompletableFuture futureOne = CompletableFuture.completedFuture(1);", + " CompletableFuture futureTwo = CompletableFuture.completedFuture(2);", + " // BUG: Diagnostic contains: Should not use CompletableFuture methods without" + + " specifying", + " futureOne.applyToEitherAsync(futureTwo, i -> i);", + " }", + "}") + .doTest(); } @Test public void should_pass_with_executor_applyToEitherAsync() { - compilationHelper.addSourceLines( - "Test.java", - "import java.util.concurrent.CompletableFuture;", - "import java.util.concurrent.Executors;", - "class Test {", - " public static final void main(String[] args) {", - " CompletableFuture futureOne = CompletableFuture.completedFuture(1);", - " CompletableFuture futureTwo = CompletableFuture.completedFuture(2);", - " futureOne.applyToEitherAsync(futureTwo, i -> i, Executors.newCachedThreadPool());", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "import java.util.concurrent.CompletableFuture;", + "import java.util.concurrent.Executors;", + "class Test {", + " public static final void main(String[] args) {", + " CompletableFuture futureOne = CompletableFuture.completedFuture(1);", + " CompletableFuture futureTwo = CompletableFuture.completedFuture(2);", + " futureOne.applyToEitherAsync(futureTwo, i -> i, Executors.newCachedThreadPool());", + " }", + "}") + .doTest(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousJsonTypeInfoUsageTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousJsonTypeInfoUsageTests.java index 6dbc91cb6..a44656a68 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousJsonTypeInfoUsageTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousJsonTypeInfoUsageTests.java @@ -83,21 +83,23 @@ public void testCustom_fullyQualified() { } private void positive(String variant) { - compilationHelper.addSourceLines( - "Bean.java", - "import com.fasterxml.jackson.annotation.JsonTypeInfo;", - "// BUG: Diagnostic contains: Must not use Jackson @JsonTypeInfo annotation", - "@JsonTypeInfo(use = " + variant + ")", - "class Bean {}" - ).doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import com.fasterxml.jackson.annotation.JsonTypeInfo;", + "// BUG: Diagnostic contains: Must not use Jackson @JsonTypeInfo annotation", + "@JsonTypeInfo(use = " + variant + ")", + "class Bean {}") + .doTest(); } private void negative(String variant) { - compilationHelper.addSourceLines( - "Bean.java", - "import com.fasterxml.jackson.annotation.JsonTypeInfo;", - "@JsonTypeInfo(use = " + variant + ")", - "class Bean {}" - ).doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import com.fasterxml.jackson.annotation.JsonTypeInfo;", + "@JsonTypeInfo(use = " + variant + ")", + "class Bean {}") + .doTest(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousStringInternUsageTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousStringInternUsageTest.java index 18ac591e0..2bee5cd27 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousStringInternUsageTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousStringInternUsageTest.java @@ -34,14 +34,15 @@ public void before() { @Test public void should_warn_when_parallel_with_no_arguments_is_invoked_on_subclass_of_java_stream() { - compilationHelper.addSourceLines( - "Test.java", - "class Test {", - " String f() {", - " // BUG: Diagnostic contains: Should not use String.intern().", - " return getClass().getName().intern();", - " }", - "}" - ).doTest(); + compilationHelper + .addSourceLines( + "Test.java", + "class Test {", + " String f() {", + " // BUG: Diagnostic contains: Should not use String.intern().", + " return getClass().getName().intern();", + " }", + "}") + .doTest(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThreadPoolExecutorUsageTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThreadPoolExecutorUsageTests.java index 02843ff5e..9bb8cb39a 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThreadPoolExecutorUsageTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThreadPoolExecutorUsageTests.java @@ -22,22 +22,22 @@ public void before() { @Test public void testThrowsOnThreadPoolExecutor() { - compilationHelper.addSourceLines( - "Bean.java", - "import java.util.concurrent.ThreadPoolExecutor;", - "import java.util.concurrent.ExecutorService;", - "class Bean {", - "// BUG: Diagnostic contains: Should not normally use ThreadPoolExecutor directly.", - "ExecutorService executor = new ThreadPoolExecutor(1, 1, 1, null, null);", - "}").doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import java.util.concurrent.ThreadPoolExecutor;", + "import java.util.concurrent.ExecutorService;", + "class Bean {", + "// BUG: Diagnostic contains: Should not normally use ThreadPoolExecutor directly.", + "ExecutorService executor = new ThreadPoolExecutor(1, 1, 1, null, null);", + "}") + .doTest(); } @Test public void testDoesNotThrowWithoutThreadPoolExecutor() { - compilationHelper.addSourceLines( - "Bean.java", - "class Bean {", - "String value = null;", - "}").doTest(); + compilationHelper + .addSourceLines("Bean.java", "class Bean {", "String value = null;", "}") + .doTest(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThrowableMessageSafeArgTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThrowableMessageSafeArgTest.java index 6d03d9dc4..54d634348 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThrowableMessageSafeArgTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/DangerousThrowableMessageSafeArgTest.java @@ -36,68 +36,78 @@ public void before() { @Test public void unsafe_safearg_value() { - compilationHelper.addSourceLines( - "Bean.java", - "import " + SafeIllegalArgumentException.class.getName() + ';', - "import " + SafeArg.class.getName() + ';', - "class Bean {", - " public SafeArg foo() {", - " Exception foo = new SafeIllegalArgumentException(\"Foo\");", - " // BUG: Diagnostic contains: Do not use throwable messages as SafeArg values", - " return SafeArg.of(\"foo\", foo.getMessage());", - " }", - "}").doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import " + SafeIllegalArgumentException.class.getName() + ';', + "import " + SafeArg.class.getName() + ';', + "class Bean {", + " public SafeArg foo() {", + " Exception foo = new SafeIllegalArgumentException(\"Foo\");", + " // BUG: Diagnostic contains: Do not use throwable messages as SafeArg values", + " return SafeArg.of(\"foo\", foo.getMessage());", + " }", + "}") + .doTest(); } @Test public void safe_safearg_value() { - compilationHelper.addSourceLines( - "Bean.java", - "import " + SafeIllegalArgumentException.class.getName() + ';', - "import " + SafeArg.class.getName() + ';', - "class Bean {", - " public SafeArg foo() {", - " SafeIllegalArgumentException foo = new SafeIllegalArgumentException(\"Foo\");", - " return SafeArg.of(\"foo\", foo.getLogMessage());", - " }", - "}").doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import " + SafeIllegalArgumentException.class.getName() + ';', + "import " + SafeArg.class.getName() + ';', + "class Bean {", + " public SafeArg foo() {", + " SafeIllegalArgumentException foo = new SafeIllegalArgumentException(\"Foo\");", + " return SafeArg.of(\"foo\", foo.getLogMessage());", + " }", + "}") + .doTest(); } @Test public void unsafe_safearg_throwable() { - compilationHelper.addSourceLines( - "Bean.java", - "import " + SafeIllegalArgumentException.class.getName() + ';', - "import " + SafeArg.class.getName() + ';', - "class Bean {", - " public SafeArg foo() {", - " // BUG: Diagnostic contains: Do not use throwables as SafeArg values", - " return SafeArg.of(\"foo\", new SafeIllegalArgumentException(\"Foo\"));", - " }", - "}").doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import " + SafeIllegalArgumentException.class.getName() + ';', + "import " + SafeArg.class.getName() + ';', + "class Bean {", + " public SafeArg foo() {", + " // BUG: Diagnostic contains: Do not use throwables as SafeArg values", + " return SafeArg.of(\"foo\", new SafeIllegalArgumentException(\"Foo\"));", + " }", + "}") + .doTest(); } @Test public void safe_null_allowed() { - compilationHelper.addSourceLines( - "Bean.java", - "import " + SafeArg.class.getName() + ';', - "class Bean {", - " public SafeArg foo() {", - " return SafeArg.of(\"foo\", null);", - " }", - "}").doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import " + SafeArg.class.getName() + ';', + "class Bean {", + " public SafeArg foo() {", + " return SafeArg.of(\"foo\", null);", + " }", + "}") + .doTest(); } @Test public void safe_object_allowed() { - compilationHelper.addSourceLines( - "Bean.java", - "import " + SafeArg.class.getName() + ';', - "class Bean {", - " public SafeArg foo(Object object) {", - " return SafeArg.of(\"foo\", object);", - " }", - "}").doTest(); + compilationHelper + .addSourceLines( + "Bean.java", + "import " + SafeArg.class.getName() + ';', + "class Bean {", + " public SafeArg foo(Object object) {", + " return SafeArg.of(\"foo\", object);", + " }", + "}") + .doTest(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ExecutorSubmitRunnableFutureIgnoredTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ExecutorSubmitRunnableFutureIgnoredTest.java index afe2eddd6..4020f1544 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ExecutorSubmitRunnableFutureIgnoredTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/ExecutorSubmitRunnableFutureIgnoredTest.java @@ -48,27 +48,31 @@ void testFix() { @Test void testNegative() { - CompilationTestHelper.newInstance(ExecutorSubmitRunnableFutureIgnored.class, getClass()).addSourceLines( - "Test.java", - "import " + ExecutorService.class.getName() + ';', - "import " + Future.class.getName() + ';', - "class Test {", - " void f(ExecutorService exec) {", - " Future future = exec.submit(() -> System.out.println(\"Hello\"));", - " }", - "}").doTest(); + CompilationTestHelper.newInstance(ExecutorSubmitRunnableFutureIgnored.class, getClass()) + .addSourceLines( + "Test.java", + "import " + ExecutorService.class.getName() + ';', + "import " + Future.class.getName() + ';', + "class Test {", + " void f(ExecutorService exec) {", + " Future future = exec.submit(() -> System.out.println(\"Hello\"));", + " }", + "}") + .doTest(); } @Test void testMessage() { - CompilationTestHelper.newInstance(ExecutorSubmitRunnableFutureIgnored.class, getClass()).addSourceLines( - "Test.java", - "import " + ExecutorService.class.getName() + ';', - "class Test {", - " void f(ExecutorService exec) {", - " // BUG: Diagnostic contains: not logged by the uncaught exception handler", - " exec.submit(() -> System.out.println(\"Hello\"));", - " }", - "}").doTest(); + CompilationTestHelper.newInstance(ExecutorSubmitRunnableFutureIgnored.class, getClass()) + .addSourceLines( + "Test.java", + "import " + ExecutorService.class.getName() + ';', + "class Test {", + " void f(ExecutorService exec) {", + " // BUG: Diagnostic contains: not logged by the uncaught exception handler", + " exec.submit(() -> System.out.println(\"Hello\"));", + " }", + "}") + .doTest(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/GuavaPreconditionsConstantMessageTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/GuavaPreconditionsConstantMessageTests.java index 694513bfa..612277e45 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/GuavaPreconditionsConstantMessageTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/GuavaPreconditionsConstantMessageTests.java @@ -46,8 +46,8 @@ public void testCheckArgument_stringConcatenate() { @Test public void testCheckArgument_stringFormat() { - failGuava(DIAGNOSTIC, - "Preconditions.checkArgument(param != \"string\", String.format(\"constant %s\", param));"); + failGuava( + DIAGNOSTIC, "Preconditions.checkArgument(param != \"string\", String.format(\"constant %s\", param));"); } @Test @@ -57,8 +57,7 @@ public void testCheckState_stringConcatenate() { @Test public void testCheckState_stringFormat() { - failGuava(DIAGNOSTIC, - "Preconditions.checkState(param != \"string\", String.format(\"constant %s\", param));"); + failGuava(DIAGNOSTIC, "Preconditions.checkState(param != \"string\", String.format(\"constant %s\", param));"); } @Test diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/LogSafePreconditionsMessageFormatTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/LogSafePreconditionsMessageFormatTests.java index 509dcb364..30967773c 100755 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/LogSafePreconditionsMessageFormatTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/LogSafePreconditionsMessageFormatTests.java @@ -42,73 +42,91 @@ public CompilationTestHelper compilationHelper() { @Test public void testCheckArgument_printf() { - failLogSafe(PRINTF_DIAGNOSTIC, "Preconditions.checkArgument(param != \"string\", \"message %s\"," - + " UnsafeArg.of(\"long\", 123L));"); + failLogSafe( + PRINTF_DIAGNOSTIC, + "Preconditions.checkArgument(param != \"string\", \"message %s\"," + " UnsafeArg.of(\"long\", 123L));"); } @Test public void testCheckArgument_multipleArgs_printf() { - failLogSafe(PRINTF_DIAGNOSTIC, "Preconditions.checkArgument(param != \"string\", \"message %s %s\"," - + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); + failLogSafe( + PRINTF_DIAGNOSTIC, + "Preconditions.checkArgument(param != \"string\", \"message %s %s\"," + + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); } @Test public void testCheckState_printf() { - failLogSafe(PRINTF_DIAGNOSTIC, "Preconditions.checkState(param != \"string\", \"message %s\"," - + " UnsafeArg.of(\"long\", 123L));"); + failLogSafe( + PRINTF_DIAGNOSTIC, + "Preconditions.checkState(param != \"string\", \"message %s\"," + " UnsafeArg.of(\"long\", 123L));"); } @Test public void testCheckState_multipleArgs_printf() { - failLogSafe(PRINTF_DIAGNOSTIC, "Preconditions.checkState(param != \"string\", \"message %s %s\"," - + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); + failLogSafe( + PRINTF_DIAGNOSTIC, + "Preconditions.checkState(param != \"string\", \"message %s %s\"," + + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); } @Test public void testCheckNotNull_printf() { - failLogSafe(PRINTF_DIAGNOSTIC, "Preconditions.checkNotNull(param, \"message %s\"," - + " UnsafeArg.of(\"long\", 123L));"); + failLogSafe( + PRINTF_DIAGNOSTIC, + "Preconditions.checkNotNull(param, \"message %s\"," + " UnsafeArg.of(\"long\", 123L));"); } @Test public void testCheckNotNull_multipleArgs_printf() { - failLogSafe(PRINTF_DIAGNOSTIC, "Preconditions.checkNotNull(param, \"message %s %s\"," - + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); + failLogSafe( + PRINTF_DIAGNOSTIC, + "Preconditions.checkNotNull(param, \"message %s %s\"," + + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); } @Test public void testCheckArgument_slf4j() { - failLogSafe(SLF4J_DIAGNOSTIC, "Preconditions.checkArgument(param != \"string\", \"message {}\"," - + " UnsafeArg.of(\"long\", 123L));"); + failLogSafe( + SLF4J_DIAGNOSTIC, + "Preconditions.checkArgument(param != \"string\", \"message {}\"," + " UnsafeArg.of(\"long\", 123L));"); } @Test public void testCheckArgument_multipleArgs_slf4j() { - failLogSafe(SLF4J_DIAGNOSTIC, "Preconditions.checkArgument(param != \"string\", \"message {} {}\"," - + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); + failLogSafe( + SLF4J_DIAGNOSTIC, + "Preconditions.checkArgument(param != \"string\", \"message {} {}\"," + + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); } @Test public void testCheckState_slf4j() { - failLogSafe(SLF4J_DIAGNOSTIC, "Preconditions.checkState(param != \"string\", \"message {}\"," - + " UnsafeArg.of(\"long\", 123L));"); + failLogSafe( + SLF4J_DIAGNOSTIC, + "Preconditions.checkState(param != \"string\", \"message {}\"," + " UnsafeArg.of(\"long\", 123L));"); } @Test public void testCheckState_multipleArgs_slf4j() { - failLogSafe(SLF4J_DIAGNOSTIC, "Preconditions.checkState(param != \"string\", \"message {} {}\"," - + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); + failLogSafe( + SLF4J_DIAGNOSTIC, + "Preconditions.checkState(param != \"string\", \"message {} {}\"," + + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); } @Test public void testCheckNotNull_slf4j() { - failLogSafe(SLF4J_DIAGNOSTIC, "Preconditions.checkNotNull(param, \"message {}\"," - + " UnsafeArg.of(\"long\", 123L));"); + failLogSafe( + SLF4J_DIAGNOSTIC, + "Preconditions.checkNotNull(param, \"message {}\"," + " UnsafeArg.of(\"long\", 123L));"); } @Test public void testCheckNotNull_multipleArgs_slf4j() { - failLogSafe(SLF4J_DIAGNOSTIC, "Preconditions.checkNotNull(param, \"message {} {}\"," - + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); + failLogSafe( + SLF4J_DIAGNOSTIC, + "Preconditions.checkNotNull(param, \"message {} {}\"," + + " UnsafeArg.of(\"char1\", 'a'), UnsafeArg.of(\"char2\", 'b'));"); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/OptionalOrElseMethodInvocationTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/OptionalOrElseMethodInvocationTests.java index 8fe606eed..276f7697a 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/OptionalOrElseMethodInvocationTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/OptionalOrElseMethodInvocationTests.java @@ -32,8 +32,7 @@ public final class OptionalOrElseMethodInvocationTests { @BeforeEach public void before() { compilationHelper = CompilationTestHelper.newInstance(OptionalOrElseMethodInvocation.class, getClass()); - refactoringTestHelper = RefactoringValidator.of( - new OptionalOrElseMethodInvocation(), getClass()); + refactoringTestHelper = RefactoringValidator.of(new OptionalOrElseMethodInvocation(), getClass()); } @Test diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferListsPartitionTests.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferListsPartitionTests.java index 479cbbd0f..ae1910111 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferListsPartitionTests.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/PreferListsPartitionTests.java @@ -55,7 +55,6 @@ public void may_use_Iterables_partition_for_Iterable() { .doTest(); } - @Test public void may_use_Iterables_partition_for_Set() { CompilationTestHelper.newInstance(PreferListsPartition.class, getClass()) @@ -111,5 +110,4 @@ public void auto_fix_Iterables_partition() { "}") .doTest(BugCheckerRefactoringTestHelper.TestMode.TEXT_MATCH); } - } diff --git a/gradle.properties b/gradle.properties index 64998c6e1..036832a43 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,3 @@ com.palantir.baseline-versions.disable = true org.gradle.parallel=true +com.palantir.baseline-format.palantir-java-format=started