Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline most {BugCheckerRefactoring,Compilation}TestHelper fields #442

Merged
merged 4 commits into from
Jan 8, 2023

Conversation

rickie
Copy link
Member

@rickie rickie commented Jan 4, 2023

As discussed in #426 (comment).

@rickie
Copy link
Member Author

rickie commented Jan 4, 2023

Suggested commit message:

Inline single-use `CompilationTestHelper` and `BugCheckerRefactoringTestHelper` variables (#442)

@rickie rickie added this to the 0.7.0 milestone Jan 4, 2023
@github-actions
Copy link

github-actions bot commented Jan 4, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think we had a misunderstanding. We can simply inline all helpers that are used in only a single test, right? (And perhaps even if they are reused?)

@rickie rickie modified the milestones: 0.7.0, 0.8.0 Jan 6, 2023
@rickie rickie force-pushed the rossendrijver/inline_restricted_compilation_helpers branch from 2e5527f to d4ce9e6 Compare January 6, 2023 14:30
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member Author

rickie commented Jan 6, 2023

The only one where it would make the test clearer is the RefasterTest. Now that test is a bit too big if you ask me. WDYT?

@rickie rickie requested a review from chamil-prabodha January 6, 2023 14:34
Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick Github UI-based review :)

Comment on lines 28 to 52
private final CompilationTestHelper compilationHelper =
CompilationTestHelper.newInstance(Refaster.class, getClass())
.matchAllDiagnostics()
.expectErrorMessage(
"StringOfSizeZeroRule",
containsPattern(
"\\[Refaster Rule\\] FooRules\\.StringOfSizeZeroRule: Refactoring opportunity\\s+.+\\s+"))
.expectErrorMessage(
"StringOfSizeOneRule",
containsPattern(
"\\[Refaster Rule\\] FooRules\\.StringOfSizeOneRule: "
+ "A custom description about matching single-char strings\\s+.+\\s+"
+ "\\(see https://error-prone.picnic.tech/refasterrules/FooRules#StringOfSizeOneRule\\)"))
.expectErrorMessage(
"StringOfSizeTwoRule",
containsPattern(
"\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeTwoRule: "
+ "A custom subgroup description\\s+.+\\s+"
+ "\\(see https://example.com/rule/FooRules#ExtraGrouping.StringOfSizeTwoRule\\)"))
.expectErrorMessage(
"StringOfSizeThreeRule",
containsPattern(
"\\[Refaster Rule\\] FooRules\\.ExtraGrouping\\.StringOfSizeThreeRule: "
+ "A custom description about matching three-char strings\\s+.+\\s+"
+ "\\(see https://example.com/custom\\)"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is now duplicated 😬

Comment on lines 21 to 22
private final CompilationTestHelper compilationTestHelper =
CompilationTestHelper.newInstance(TestChecker.class, getClass());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here 100% of tests use this field; I'd keep this one as-is.

@@ -54,7 +48,7 @@ void identification() {

@Test
void replacementFirstSuggestedFix() {
refactoringTestHelper
newInstance(StringCaseLocaleUsage.class, getClass())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
newInstance(StringCaseLocaleUsage.class, getClass())
BugCheckerRefactoringTestHelper.newInstance(StringCaseLocaleUsage.class, getClass())

Likewise below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started working on that upstream fix. Will do that after applying this feedback.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// XXX: Can we perhaps work-around this by describing the fixes in reverse order?

// The logic for `char` and `short` is exactly analogous to the `byte` case.
/* The logic for `char` and `short` is exactly analogous to the `byte` case. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* The logic for `char` and `short` is exactly analogous to the `byte` case. */
/** @implNote The logic for `char` and `short` is exactly analogous to the `byte` case. */

Perhaps.

@@ -10,19 +10,9 @@
// `String.valueOf(null)` may not. That is because the latter matches `String#valueOf(char[])`. We
// could special-case `null` arguments, but that doesn't seem worth the trouble.
final class RedundantStringConversionTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is an edge case, w.r.t. field reuse 🤔

Copy link
Member Author

@rickie rickie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a commit with all feedback fixed.

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@@ -73,7 +67,7 @@ void identification() {

@Test
void replacementFirstSuggestedFix() {
refactoringTestHelper
newInstance(FluxFlatMapUsage.class, getClass())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can apply the same for the method below as well.

Suggested change
newInstance(FluxFlatMapUsage.class, getClass())
BugCheckerRefactoringTestHelper.newInstance(FluxFlatMapUsage.class, getClass())

Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one more commit. Nice!

Suggested commit message:

Inline most `{BugCheckerRefactoring,Compilation}TestHelper` fields (#442)

@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie force-pushed the rossendrijver/inline_restricted_compilation_helpers branch from d64afa2 to 5077920 Compare January 8, 2023 11:18
@github-actions
Copy link

github-actions bot commented Jan 8, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member Author

rickie commented Jan 8, 2023

Made a tweak to the suggested commit message and sorted the two entries. This fits the number of characters, WDYT?

@Stephan202
Copy link
Member

Works for me 👍

@rickie rickie changed the title Inline CompilationTestHelpers that specify command-line arguments Inline most {BugCheckerRefactoring,Compilation}TestHelper fields Jan 8, 2023
@rickie rickie merged commit 9bd4b16 into master Jan 8, 2023
@rickie rickie deleted the rossendrijver/inline_restricted_compilation_helpers branch January 8, 2023 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants