Skip to content

Commit

Permalink
Suppress mutable execution context warnings for now (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Jan 17, 2025
1 parent 7c52792 commit 3018587
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation mi, Execution
result = template.apply(getCursor(), mi.getCoordinates().replace(), mi.getArguments().get(0));
}

ctx.putMessage(result.toString(), !logicalContext);
ctx.putMessage(result.toString(), !logicalContext); // FIXME Do not store on the use execution context

return result;
} else {
if (ctx.pollMessage(mi.toString()) == null) {
ctx.putMessage(mi.toString(), true);
ctx.putMessage(mi.toString(), true); // FIXME Do not store on the use execution context
}
}
return super.visitMethodInvocation(mi, ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.test.TypeValidation.all;

class HamcrestInstanceOfToJUnit5Test implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec
.parser(JavaParser.fromJavaVersion()
.classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5.9", "hamcrest-2.2"))
.recipe(new HamcrestInstanceOfToJUnit5());
.recipe(new HamcrestInstanceOfToJUnit5())
.typeValidationOptions(all().immutableExecutionContext(false));
}

@DocumentExample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.test.TypeValidation.all;

class HamcrestMatcherToJUnit5Test implements RewriteTest {
@Override
Expand Down Expand Up @@ -122,6 +123,7 @@ void testEquals() {
void notEqualToString() {
//language=java
rewriteRun(
spec -> spec.typeValidationOptions(all().immutableExecutionContext(false)),
java(
"""
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -464,6 +466,7 @@ void testNullValue() {
void sameInstance() {
//language=java
rewriteRun(
spec -> spec.typeValidationOptions(all().immutableExecutionContext(false)),
java(
"""
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.test.TypeValidation.all;

class MigrateHamcrestToJUnitTest implements RewriteTest {
@Override
Expand All @@ -38,6 +39,7 @@ public void defaults(RecipeSpec spec) {
void equalToString() {
//language=java
rewriteRun(
spec -> spec.typeValidationOptions(all().immutableExecutionContext(false)),
java(
"""
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.test.RewriteTest.toRecipe;
import static org.openrewrite.test.TypeValidation.all;

class RemoveNotMatcherTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec
.parser(JavaParser.fromJavaVersion()
.classpathFromResources(new InMemoryExecutionContext(), "junit-jupiter-api-5.9", "hamcrest-2.2"))
.recipe(toRecipe(RemoveNotMatcherVisitor::new));
.recipe(toRecipe(RemoveNotMatcherVisitor::new))
.typeValidationOptions(all().immutableExecutionContext(false));
}

@DocumentExample
@Test
void nestedNotMatcher() {
rewriteRun(
//language=java
Expand Down

0 comments on commit 3018587

Please sign in to comment.