diff --git a/src/test/java/org/openrewrite/analysis/controlflow/GuardTest.java b/src/test/java/org/openrewrite/analysis/controlflow/GuardTest.java index 86d77bc05..a0b7e14f7 100644 --- a/src/test/java/org/openrewrite/analysis/controlflow/GuardTest.java +++ b/src/test/java/org/openrewrite/analysis/controlflow/GuardTest.java @@ -283,6 +283,7 @@ void test() { @Test void identifiesGuardsForControlParenthesesWithMissingTypeInformation() { rewriteRun( + spec -> spec.typeValidationOptions(TypeValidation.builder().identifiers(false).build()), java( """ class Test { @@ -309,6 +310,7 @@ void test() { @Test void doesNotFlagArbitraryParenthesesAsGuards() { rewriteRun( + spec -> spec.typeValidationOptions(TypeValidation.builder().identifiers(false).build()), java( """ class Test { diff --git a/src/test/java/org/openrewrite/analysis/dataflow/DataflowFunctionalTest.java b/src/test/java/org/openrewrite/analysis/dataflow/DataflowFunctionalTest.java index c212c8976..281661ef2 100644 --- a/src/test/java/org/openrewrite/analysis/dataflow/DataflowFunctionalTest.java +++ b/src/test/java/org/openrewrite/analysis/dataflow/DataflowFunctionalTest.java @@ -25,6 +25,7 @@ import org.openrewrite.java.tree.Expression; import org.openrewrite.java.tree.J; import org.openrewrite.test.RewriteTest; +import org.openrewrite.test.TypeValidation; import java.util.stream.Stream; @@ -45,46 +46,48 @@ static Stream fileProvider() { void eachJavaFile(String input) { rewriteRun( spec -> spec.recipe(toRecipe(() -> new JavaIsoVisitor<>() { - @Override - public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) { - // Force a case where data flow occurs inside a doAfterVisit on a non-top-level visitor run. - new JavaIsoVisitor() { - @Override - public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { - // The doAfterVisit - doAfterVisit(new JavaIsoVisitor<>() { - @Override - public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { - doRunDataFlow(); - return super.visitMethodInvocation(method, ctx); - } - }); - return method; - } - }.visitNonNull(classDecl, ctx, getCursor().getParentOrThrow()); - return super.visitClassDeclaration(classDecl, ctx); - } + @Override + public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) { + // Force a case where data flow occurs inside a doAfterVisit on a non-top-level visitor run. + new JavaIsoVisitor() { + @Override + public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) { + // The doAfterVisit + doAfterVisit(new JavaIsoVisitor<>() { + @Override + public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { + doRunDataFlow(); + return super.visitMethodInvocation(method, ctx); + } + }); + return method; + } + }.visitNonNull(classDecl, ctx, getCursor().getParentOrThrow()); + return super.visitClassDeclaration(classDecl, ctx); + } - @Override - public Expression visitExpression(Expression expression, ExecutionContext executionContext) { - doRunDataFlow(); - return super.visitExpression(expression, executionContext); - } + @Override + public Expression visitExpression(Expression expression, ExecutionContext executionContext) { + doRunDataFlow(); + return super.visitExpression(expression, executionContext); + } - private void doRunDataFlow() { - Dataflow.startingAt(getCursor()).findSinks(new TaintFlowSpec() { - @Override - public boolean isSource(DataFlowNode srcNode) { - return true; - } + private void doRunDataFlow() { + Dataflow.startingAt(getCursor()).findSinks(new TaintFlowSpec() { + @Override + public boolean isSource(DataFlowNode srcNode) { + return true; + } - @Override - public boolean isSink(DataFlowNode sinkNode) { - return true; - } - }); - } - })).cycles(1), + @Override + public boolean isSink(DataFlowNode sinkNode) { + return true; + } + }); + } + })) + .cycles(1) + .typeValidationOptions(TypeValidation.none()), java( StringUtils.readFully(requireNonNull(DataflowFunctionalTest.class .getResourceAsStream("/" + input))) diff --git a/src/test/java/org/openrewrite/analysis/trait/expr/LiteralTest.java b/src/test/java/org/openrewrite/analysis/trait/expr/LiteralTest.java index 44fd7268b..ea1d71d71 100644 --- a/src/test/java/org/openrewrite/analysis/trait/expr/LiteralTest.java +++ b/src/test/java/org/openrewrite/analysis/trait/expr/LiteralTest.java @@ -262,7 +262,7 @@ void noLiteralsPresent() { """ class Test { boolean test(int i, float f, double d, char c, String s) { - boolean b1 = s.contains(c.toString()); + boolean b1 = s.contains(Character.toString(c)); if (b1 && i - f == d) { return i > d; } else { diff --git a/src/test/java/org/openrewrite/analysis/trait/variable/JavadocTest.java b/src/test/java/org/openrewrite/analysis/trait/variable/JavadocTest.java index ad9b43825..5d7d12c9b 100644 --- a/src/test/java/org/openrewrite/analysis/trait/variable/JavadocTest.java +++ b/src/test/java/org/openrewrite/analysis/trait/variable/JavadocTest.java @@ -23,6 +23,7 @@ import org.openrewrite.marker.SearchResult; import org.openrewrite.test.RecipeSpec; import org.openrewrite.test.RewriteTest; +import org.openrewrite.test.TypeValidation; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.openrewrite.java.Assertions.java; @@ -167,6 +168,7 @@ void foo() throws IOException { @Test void javadocWithLink() { rewriteRun( + spec -> spec.typeValidationOptions(TypeValidation.builder().methodInvocations(false).build()), java( """ class Test { diff --git a/src/test/resources/dataflow-functional-tests/FileUtils.java b/src/test/resources/dataflow-functional-tests/FileUtils.java index 74d1985d0..e94839241 100644 --- a/src/test/resources/dataflow-functional-tests/FileUtils.java +++ b/src/test/resources/dataflow-functional-tests/FileUtils.java @@ -113,7 +113,7 @@ public FileUtils() { /** * An empty array of type File. */ - public static final File[] EMPTY_FILE_ARRAY = new File.get(0); + public static final File[] EMPTY_FILE_ARRAY = new File[0]; /** * The UTF-8 character set, used to decode octets in URLs.