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

Move files and resources to .refastertemplates packages #113

Merged
merged 8 commits into from
Jun 1, 2022

Conversation

rickie
Copy link
Member

@rickie rickie commented May 25, 2022

This commit is to prepare the code for #43.
Here we already move the templates and associated resources.

Note that for the RefasterCheckTest, RefasterTemplateTestCase, and RefasterCheckTest there are some temporary changes. In #43 most things will be moved to refaster-test-support or refaster-runner. They are currently moved as to make the existing state work.

@rickie rickie requested review from Stephan202 and Badbond May 25, 2022 14:27
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.

Some context.

@@ -196,10 +194,7 @@ private static ImmutableListMultimap<String, CodeTransformer> loadAllCodeTransfo

private static ImmutableSet<ResourceInfo> getClassPathResources() {
try {
return ClassPath.from(
Copy link
Member Author

Choose a reason for hiding this comment

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

This change is copied over from here.

@@ -68,9 +66,9 @@ public final class RefasterCheck extends BugChecker implements CompilationUnitTr
private static final String REFASTER_TEMPLATE_SUFFIX = ".refaster";
private static final String INCLUDED_TEMPLATES_PATTERN_FLAG = "Refaster:NamePattern";

@VisibleForTesting
Copy link
Member Author

Choose a reason for hiding this comment

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

This will also change in the "end-state" implementation.

@rickie rickie added this to the 0.1.0 milestone May 25, 2022
@rickie rickie force-pushed the rossendrijver/move_refastertemplates branch from 8269b7b to 7b8da2d Compare May 26, 2022 12:33
@rickie
Copy link
Member Author

rickie commented May 26, 2022

(Not yet fixed) 😄

@rickie rickie force-pushed the rossendrijver/move_refastertemplates branch from 7b8da2d to 082d0de Compare May 26, 2022 18:10
@rickie
Copy link
Member Author

rickie commented May 26, 2022

Fixed now :).

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 two commits; TBD whether both make sense in the context of #43. (Hope to review that PR ~tomorrow.)

Comment on lines 20 to 22
import tech.picnic.errorprone.bugpatterns.RefasterCheck;

public final class RefasterCheckTest {
Copy link
Member

Choose a reason for hiding this comment

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

So the test is now in a different package than the main class. As discussed, this is to work around a limitation of the current test setup, to be resolved in an upcoming PR. Let's add a comment to that effect.

Copy link
Member

@Stephan202 Stephan202 May 28, 2022

Choose a reason for hiding this comment

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

Actually, we can avoid the move using another few-line change. Not elegant, but IMHO preferable to moving the class.

(TBD whether this insight allows simplifications in #43; didn't scrutinize that PR yet.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure whether I agree that this is better, but as is it a temporary state I'm OK with it 😄.

Copy link
Member Author

Choose a reason for hiding this comment

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

The RefasterCheck will go to the refaster-runner module in #43.

@VisibleForTesting
static final Supplier<ImmutableListMultimap<String, CodeTransformer>> ALL_CODE_TRANSFORMERS =
Suppliers.memoize(RefasterCheck::loadAllCodeTransformers);
/** All code transformers loaded by {@link RefasterCheck}. */
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
/** All code transformers loaded by {@link RefasterCheck}. */
/** All code transformers found on the classpath, loaded lazily. */

@Stephan202
Copy link
Member

Build fails because of:

[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ error-prone-contrib ---
[INFO] Compiling 28 source files to /home/sschroevers/workspace/picnic/error-prone-support/error-prone-contrib/target/test-classes
[INFO] -------------------------------------------------------------
[WARN] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARN] /home/sschroevers/workspace/picnic/error-prone-support/error-prone-contrib/src/test/java/tech/picnic/errorprone/bugpatterns/RefasterCheckTest.java:[185,11] [BooleanParameter] Use parameter comments to document ambiguous literals
    (see https://errorprone.info/bugpattern/BooleanParameter)
  Did you mean '/* initialize= */false,'?
[INFO] 1 warning

I didn't see this error locally. Turns out that this error triggers when building with JDK 11, but not when building with JDK 17. In the latter case the BooleanParameter check backs off following this check, because Class#forName's parameters are reported as arg0, arg1 and arg2. I tried to "fix" this by adding --add-exports=java.base/java.lang=ALL-UNNAMED and --add-opens=java.base/java.lang=ALL-UNNAMED to .mvn/jvm.config, but that didn't help. Won't investigate further; added a commit to resolve the warning.

@rickie rickie force-pushed the rossendrijver/move_refastertemplates branch from 9588d46 to b31a789 Compare May 31, 2022 12:11
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.

Suggested commit message:

Move Refaster template test resources to proper package (#113)

@rickie
Copy link
Member Author

rickie commented May 31, 2022

Made a tiny tweak to the suggested commit message to be more accurate.

@Stephan202
Copy link
Member

Right. Tweaked further ;)

Copy link
Member

@Badbond Badbond left a comment

Choose a reason for hiding this comment

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

LGTM. Thought we could create a final member variable for BugCheckerRefactoringTestHelper but this didn't speed up tests much and I suspect will become a problem with Junit method parallelism.

@Stephan202
Copy link
Member

LGTM. Thought we could create a final member variable for BugCheckerRefactoringTestHelper but this didn't speed up tests much and I suspect will become a problem with Junit method parallelism.

Discussed offline. This is a good idea. However, as we'll anyway change this code in #43 we'll skip this change 👍

@Stephan202 Stephan202 merged commit 8277b43 into master Jun 1, 2022
@Stephan202 Stephan202 deleted the rossendrijver/move_refastertemplates branch June 1, 2022 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants