diff --git a/error-prone-guidelines/src/main/java/tech/picnic/errorprone/guidelines/bugpatterns/ErrorProneTestHelperSourceFormat.java b/error-prone-guidelines/src/main/java/tech/picnic/errorprone/guidelines/bugpatterns/TestHelperSourceFormat.java similarity index 96% rename from error-prone-guidelines/src/main/java/tech/picnic/errorprone/guidelines/bugpatterns/ErrorProneTestHelperSourceFormat.java rename to error-prone-guidelines/src/main/java/tech/picnic/errorprone/guidelines/bugpatterns/TestHelperSourceFormat.java index 68200aaf6a7..c06a8387ab9 100644 --- a/error-prone-guidelines/src/main/java/tech/picnic/errorprone/guidelines/bugpatterns/ErrorProneTestHelperSourceFormat.java +++ b/error-prone-guidelines/src/main/java/tech/picnic/errorprone/guidelines/bugpatterns/TestHelperSourceFormat.java @@ -69,13 +69,13 @@ summary = "Test code should follow the Google Java style (and when targeting JDK 15+ be " + "specified using a single text block)", - link = BUG_PATTERNS_BASE_URL + "ErrorProneTestHelperSourceFormat", + link = BUG_PATTERNS_BASE_URL + "TestHelperSourceFormat", linkType = CUSTOM, severity = SUGGESTION, tags = STYLE) // XXX: Drop suppression if/when the `avoidTextBlocks` field is dropped. @SuppressWarnings("java:S2160" /* Super class equality definition suffices. */) -public final class ErrorProneTestHelperSourceFormat extends BugChecker +public final class TestHelperSourceFormat extends BugChecker implements MethodInvocationTreeMatcher { private static final long serialVersionUID = 1L; private static final String FLAG_AVOID_TEXT_BLOCKS = @@ -99,7 +99,7 @@ public final class ErrorProneTestHelperSourceFormat extends BugChecker .onDescendantOf("com.google.errorprone.BugCheckerRefactoringTestHelper.ExpectOutput") .named("addOutputLines"); private static final Supplier IS_JABEL_ENABLED = - VisitorState.memoize(ErrorProneTestHelperSourceFormat::isJabelEnabled); + VisitorState.memoize(TestHelperSourceFormat::isJabelEnabled); // XXX: Proper name for this? // XXX: Something about tabs. private static final String TEXT_BLOCK_MARKER = "\"\"\""; @@ -109,18 +109,18 @@ public final class ErrorProneTestHelperSourceFormat extends BugChecker private final boolean avoidTextBlocks; - /** Instantiates a default {@link ErrorProneTestHelperSourceFormat} instance. */ - public ErrorProneTestHelperSourceFormat() { + /** Instantiates a default {@link TestHelperSourceFormat} instance. */ + public TestHelperSourceFormat() { this(ErrorProneFlags.empty()); } /** - * Instantiates a customized {@link ErrorProneTestHelperSourceFormat}. + * Instantiates a customized {@link TestHelperSourceFormat}. * * @param flags Any provided command line flags. */ @Inject - ErrorProneTestHelperSourceFormat(ErrorProneFlags flags) { + TestHelperSourceFormat(ErrorProneFlags flags) { avoidTextBlocks = flags.getBoolean(FLAG_AVOID_TEXT_BLOCKS).orElse(Boolean.FALSE); } diff --git a/error-prone-guidelines/src/test/java/tech/picnic/errorprone/guidelines/bugpatterns/ErrorProneTestHelperSourceFormatTest.java b/error-prone-guidelines/src/test/java/tech/picnic/errorprone/guidelines/bugpatterns/TestHelperSourceFormatTest.java similarity index 97% rename from error-prone-guidelines/src/test/java/tech/picnic/errorprone/guidelines/bugpatterns/ErrorProneTestHelperSourceFormatTest.java rename to error-prone-guidelines/src/test/java/tech/picnic/errorprone/guidelines/bugpatterns/TestHelperSourceFormatTest.java index 82465361b25..3f148038caf 100644 --- a/error-prone-guidelines/src/test/java/tech/picnic/errorprone/guidelines/bugpatterns/ErrorProneTestHelperSourceFormatTest.java +++ b/error-prone-guidelines/src/test/java/tech/picnic/errorprone/guidelines/bugpatterns/TestHelperSourceFormatTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.condition.DisabledForJreRange; import org.junit.jupiter.api.condition.JRE; -final class ErrorProneTestHelperSourceFormatTest { +final class TestHelperSourceFormatTest { // XXX: Add tests cases for `ErrorProneTestHelperSourceFormat:IgnoreMalformedCode`. // XXX: Consider reducing the `@DisabledForJreRange(max = JRE.JAVA_14)` test scope by moving the // text blocks to smaller test methods. @@ -15,7 +15,7 @@ final class ErrorProneTestHelperSourceFormatTest { @DisabledForJreRange(max = JRE.JAVA_14) @Test void identification() { - CompilationTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()) + CompilationTestHelper.newInstance(TestHelperSourceFormat.class, getClass()) .addSourceLines( "A.java", "import com.google.errorprone.BugCheckerRefactoringTestHelper;", @@ -76,7 +76,7 @@ void identification() { @DisabledForJreRange(max = JRE.JAVA_14) @Test void identificationAvoidTextBlocks() { - CompilationTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()) + CompilationTestHelper.newInstance(TestHelperSourceFormat.class, getClass()) .setArgs("-XepOpt:ErrorProneTestHelperSourceFormat:AvoidTextBlocks=true") .addSourceLines( "A.java", @@ -131,7 +131,7 @@ void replacement() { * imports are removed unless part of a `BugCheckerRefactoringTestHelper` expected output file. * Also verifies that text blocks are properly indented. */ - BugCheckerRefactoringTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()) + BugCheckerRefactoringTestHelper.newInstance(TestHelperSourceFormat.class, getClass()) .addInputLines( "A.java", "import com.google.errorprone.BugCheckerRefactoringTestHelper;", @@ -226,7 +226,7 @@ void replacementAvoidTextBlocks() { * Verifies that import sorting and code formatting is performed unconditionally, while unused * imports are removed unless part of a `BugCheckerRefactoringTestHelper` expected output file. */ - BugCheckerRefactoringTestHelper.newInstance(ErrorProneTestHelperSourceFormat.class, getClass()) + BugCheckerRefactoringTestHelper.newInstance(TestHelperSourceFormat.class, getClass()) .setArgs("-XepOpt:ErrorProneTestHelperSourceFormat:AvoidTextBlocks=true") .addInputLines( "in/A.java",