You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The recipe UseSystemLineSeparator fails in this test case:
UseSystemLineSeparatorTest.kt
@Test
funmigratesFieldInitializer() = assertChanged(
before =""" import org.apache.commons.io.IOUtils; class A { private final String LINE_SEPARATOR_AND_INDENTATION = IOUtils.LINE_SEPARATOR + " "; }""",
after =""" class A { private final String LINE_SEPARATOR_AND_INDENTATION = System.lineSeparator() + " "; }"""
)
This is the same issue as ChangeStaticFieldToMethod had in my original attempt (openrewrite/rewrite#1071). The issue was fixed for that class before it was merged.
Now that ChangeStaticFieldToMethod is available, the UseSystemLineSeparator recipe is merely a special case of it and could be replaced by a declarative recipe that amounts to using ChangeStaticFieldToMethod("org.apache.commons.io.IOUtils", "LINE_SEPARATOR", "java.lang.System", "lineSeparator") (as it would be written in the Kotlin test class).