From 610c1c3db413839dcdff233db289b7c3e76730d9 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sun, 27 Oct 2024 14:37:15 +0100 Subject: [PATCH] Drop unnecessary UsesType --- .../openrewrite/staticanalysis/BufferedWriterCreation.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openrewrite/staticanalysis/BufferedWriterCreation.java b/src/main/java/org/openrewrite/staticanalysis/BufferedWriterCreation.java index 109488b57..60a3c4b58 100644 --- a/src/main/java/org/openrewrite/staticanalysis/BufferedWriterCreation.java +++ b/src/main/java/org/openrewrite/staticanalysis/BufferedWriterCreation.java @@ -23,7 +23,6 @@ import org.openrewrite.java.JavaTemplate; import org.openrewrite.java.JavaVisitor; import org.openrewrite.java.search.UsesMethod; -import org.openrewrite.java.search.UsesType; import org.openrewrite.java.template.Semantics; import org.openrewrite.java.template.internal.AbstractRefasterJavaVisitor; import org.openrewrite.java.tree.J; @@ -37,7 +36,7 @@ public class BufferedWriterCreation extends Recipe { @Override public String getDisplayName() { - return "Modernize BufferedWriter creation & prevent file descriptor leak"; + return "Modernize `BufferedWriter` creation & prevent file descriptor leak"; } @Override @@ -148,12 +147,10 @@ public J visitNewClass(J.NewClass elem, ExecutionContext ctx) { } return null; } - }; + return Preconditions.check( Preconditions.and( - new UsesType<>("java.io.BufferedWriter", true), - new UsesType<>("java.io.FileWriter", true), new UsesMethod<>("java.io.BufferedWriter (..)"), new UsesMethod<>("java.io.FileWriter (..)") ),