From 4314bfd209b26ae886fba2cb1e6a47922fb1f6fb Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Fri, 8 Dec 2023 19:28:36 +0000 Subject: [PATCH] refactor: OpenRewrite recipe best practices Use this link to re-run the recipe: https://app.moderne.io/recipes/builder/XX1hrwagC?organizationId=T3BlblJld3JpdGU%3D Co-authored-by: Moderne --- .../org/openrewrite/FindDuplicateSourceFiles.java | 2 +- .../java/org/openrewrite/FindCallGraphTest.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/openrewrite/FindDuplicateSourceFiles.java b/src/main/java/org/openrewrite/FindDuplicateSourceFiles.java index b68fa5a..6253a8f 100644 --- a/src/main/java/org/openrewrite/FindDuplicateSourceFiles.java +++ b/src/main/java/org/openrewrite/FindDuplicateSourceFiles.java @@ -72,7 +72,7 @@ public Collection generate(Map> acc, Ex public TreeVisitor getVisitor(Map> acc) { return new TreeVisitor() { @Override - public Tree visit(@Nullable Tree tree, ExecutionContext executionContext) { + public Tree visit(@Nullable Tree tree, ExecutionContext ctx) { assert tree instanceof SourceFile; SourceFile s = (SourceFile) tree; if(acc.containsKey(s.getSourcePath()) && acc.get(s.getSourcePath()).size() > 1) { diff --git a/src/test/java/org/openrewrite/FindCallGraphTest.java b/src/test/java/org/openrewrite/FindCallGraphTest.java index 738309f..72af1d8 100644 --- a/src/test/java/org/openrewrite/FindCallGraphTest.java +++ b/src/test/java/org/openrewrite/FindCallGraphTest.java @@ -151,7 +151,8 @@ void staticInitializer() { ) ), //language=java - java(""" + java( + """ class Scratch { static int i = bar(); static { @@ -196,7 +197,8 @@ void initializer() { ) ), //language=java - java(""" + java( + """ class Scratch { int i = bar(); int j; @@ -243,7 +245,8 @@ void innerClass() { ) ), //language=java - java(""" + java( + """ class A { class B { void b() { @@ -279,7 +282,8 @@ void anonymousClass() { ) ) ), - java(""" + java( + """ class A { public void method() {} } @@ -318,7 +322,8 @@ void companionObject() { ) ), //language=kotlin - kotlin(""" + kotlin( + """ class A { companion object { @JvmStatic