Skip to content

Commit

Permalink
Proposal: rename check
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 committed Mar 17, 2024
1 parent 496b0b1 commit bc11baf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -99,7 +99,7 @@ public final class ErrorProneTestHelperSourceFormat extends BugChecker
.onDescendantOf("com.google.errorprone.BugCheckerRefactoringTestHelper.ExpectOutput")
.named("addOutputLines");
private static final Supplier<Boolean> 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 = "\"\"\"";
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
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.

@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;",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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;",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit bc11baf

Please sign in to comment.