Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear out empty newlines #528

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ void noSchemaCD12() {
xml(
"""
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/DDDDxml/ns/javaee22 http://xmlns.jcp.org11/xml/ns/javaee777/beans_1_1.xsd">
</beans>
</beans>
""",
"""
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
</beans>
</beans>
""",
sourceSpecs -> sourceSpecs.path("beans.xml")
)
Expand All @@ -86,10 +86,10 @@ void fileNotNamedBeansXml() {
//language=xml
xml(
"""
<beans xmlns="http://java.sun.com/xml/ns/javaee"
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
</beans>
""",
sourceSpecs -> sourceSpecs.path("not-beans.xml")
)
Expand All @@ -102,10 +102,10 @@ void alreadyHasRightSchemaLocationSun() {
//language=xml
xml(
"""
<beans xmlns="http://java.sun.com/xml/ns/javaee"
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
</beans>
""",
sourceSpecs -> sourceSpecs.path("beans.xml")
)
Expand All @@ -118,9 +118,9 @@ void alreadyHasRightSchemaLocation() {
//language=xml
xml(
"""
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all" version="1.1">
</beans>
""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void positiveCases() {
java(
"""
import java.util.Arrays;

class Foo {
void bar() {
Integer[] array1 = (Integer[]) Arrays.asList(1, 2, 3).toArray();
Expand All @@ -47,7 +47,7 @@ void bar() {
""",
"""
import java.util.Arrays;

class Foo {
void bar() {
Integer[] array1 = Arrays.asList(1, 2, 3).toArray(new Integer[0]);
Expand All @@ -68,7 +68,7 @@ void negativeCases() {
"""
import java.util.Arrays;
import java.util.Collections;

class Foo {
void bar() {
Object[] array1 = (Object[]) Arrays.asList("a","b").toArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,57 +37,59 @@ void deleteDeprecatedFinalize() {
//language=java
java(
"""
package java.awt.color;
import java.awt.color.ICC_Profile;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
public class Test {
public static void main(String[] args) {
byte ff = (byte) 0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };
ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);
// flag
profile.finalize();
ColorModel cm = new IndexColorModel(3, 5, r, g, b);
// flag
cm.finalize();
IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);
// flag
icm.finalize();
}
}
""",
package java.awt.color;

import java.awt.color.ICC_Profile;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;

public class Test {
public static void main(String[] args) {
byte ff = (byte) 0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };

ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);
// flag
profile.finalize();

ColorModel cm = new IndexColorModel(3, 5, r, g, b);

// flag
cm.finalize();

IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);
// flag
icm.finalize();

}
}
""",
"""
package java.awt.color;

import java.awt.color.ICC_Profile;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;

public class Test {
public static void main(String[] args) {
byte ff = (byte) 0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };

ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);

ColorModel cm = new IndexColorModel(3, 5, r, g, b);

IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);

}
}
"""));
package java.awt.color;

import java.awt.color.ICC_Profile;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;

public class Test {
public static void main(String[] args) {
byte ff = (byte) 0xff;
byte[] r = { ff, 0, 0, ff, 0 };
byte[] g = { 0, ff, 0, ff, 0 };
byte[] b = { 0, 0, ff, ff, 0 };

ICC_Profile profile = ICC_Profile.getInstance(ICC_Profile.CLASS_COLORSPACECONVERSION);

ColorModel cm = new IndexColorModel(3, 5, r, g, b);

IndexColorModel icm = new IndexColorModel(3, 5, r, g, b);

}
}
"""
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void deprecatedCountStackFrameRemoveMethod() {
java(
"""
import java.lang.Thread;

public class Test {
public static void main(String args[]) {
Thread t1,t2 = new Thread();
Expand All @@ -46,7 +46,7 @@ public static void main(String args[]) {
""",
"""
import java.lang.Thread;

public class Test {
public static void main(String args[]) {
Thread t1,t2 = new Thread();
Expand All @@ -64,7 +64,7 @@ void deprecatedCountStackFrameNoRemoval() {
java(
"""
import java.lang.Thread;

public class Test {
public static void main(String args[]) {
Thread t1,t2 = new Thread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String getBreed() {
java(
"""
import animals.Dog;

class Test {
boolean test(Dog dog, int age) {
if(dog.getName() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class IBMJDKtoOracleJDKTest implements RewriteTest {
void Krb5LoginModuleTest() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().dependsOn("""
package com.ibm.security.auth.module;
public class Krb5LoginModule {
public void login() {
}
}
"""))
package com.ibm.security.auth.module;
public class Krb5LoginModule {
public void login() {
}
}
"""))
.recipeFromResources("org.openrewrite.java.migrate.IBMJDKtoOracleJDK"),
//language=java
java(
Expand Down
Loading
Loading