Skip to content

Commit ae1d551

Browse files
author
Vincent Potucek
committed
ReplaceObsoletes
1 parent 9db6d6e commit ae1d551

File tree

4 files changed

+164
-3
lines changed

4 files changed

+164
-3
lines changed

lib/src/main/java/com/diffplug/spotless/sql/dbeaver/SQLTokenizedFormatter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ private boolean isFunction(String name) {
388388
return sqlDialect.getKeywordType(name) == DBPKeywordType.FUNCTION;
389389
}
390390

391+
// TODO test for this and remove the whole m,etnhoid.
391392
private static String getDefaultLineSeparator() {
392393
return System.getProperty("line.separator", "\n");
393394
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/java/ReplaceObsoletesStepTest.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2024 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,18 +16,48 @@
1616
package com.diffplug.spotless.maven.java;
1717

1818
import com.diffplug.spotless.maven.MavenIntegrationHarness;
19-
2019
import org.junit.jupiter.api.Test;
2120

2221
class ReplaceObsoletesStepTest extends MavenIntegrationHarness {
2322

2423
@Test
25-
void testRemoveUnusedImports() throws Exception {
24+
void testDefaults() throws Exception {
2625
writePomWithJavaSteps("<replaceObsoletes/>");
2726

2827
String path = "src/main/java/test.java";
2928
setFile(path).toResource("java/replaceobsoletes/ReplaceObsoletesPre.test");
3029
mavenRunner().withArguments("spotless:apply").runNoError();
3130
assertFile(path).sameAsResource("java/replaceobsoletes/ReplaceObsoletesPost.test");
3231
}
32+
33+
@Test
34+
void testSystemLineSeparator() throws Exception {
35+
writePomWithJavaSteps("<replaceObsoletes/>");
36+
37+
String path = "src/main/java/test.java";
38+
setFile(path).toResource("java/replaceobsoletes/SystemLineSeparatorPre.test");
39+
mavenRunner().withArguments("spotless:apply").runNoError();
40+
assertFile(path).sameAsResource("java/replaceobsoletes/SystemLineSeparatorPost.test");
41+
}
42+
43+
@Test
44+
void testBooleanInitializers() throws Exception {
45+
writePomWithJavaSteps("<replaceObsoletes/>");
46+
47+
String path = "src/main/java/test.java";
48+
setFile(path).toResource("java/replaceobsoletes/BooleanInitializersPre.test");
49+
mavenRunner().withArguments("spotless:apply").runNoError();
50+
assertFile(path).sameAsResource("java/replaceobsoletes/BooleanInitializersPost.test");
51+
}
52+
53+
@Test
54+
void testNullInitializers() throws Exception {
55+
writePomWithJavaSteps("<replaceObsoletes/>");
56+
57+
String path = "src/main/java/test.java";
58+
setFile(path).toResource("java/replaceobsoletes/NullInitializersPre.test");
59+
mavenRunner().withArguments("spotless:apply").runNoError();
60+
assertFile(path).sameAsResource("java/replaceobsoletes/NullInitializersPost.test");
61+
}
62+
3363
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2021-2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.diffplug.spotless.pom;
17+
18+
import java.io.Serializable;
19+
20+
// Class and members must be public, otherwise we get failed to access class com.diffplug.spotless.pom.SortPomInternalState from class com.diffplug.spotless.pom.SortPomFormatterFunc (com.diffplug.spotless.pom.SortPomInternalState is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @682bd3c4; com.diffplug.spotless.pom.SortPomFormatterFunc is in unnamed module of loader com.diffplug.spotless.pom.DelegatingClassLoader @573284a5)
21+
public class SortPomCfg implements Serializable {
22+
private static final long serialVersionUID = 1L;
23+
24+
public String version = "4.0.0";
25+
26+
public String encoding = "UTF-8";
27+
28+
public String lineSeparator = System.getProperty("line.separator");
29+
30+
public boolean expandEmptyElements = true;
31+
32+
public boolean spaceBeforeCloseEmptyElement = false;
33+
34+
public boolean keepBlankLines = true;
35+
36+
public boolean endWithNewline = true;
37+
38+
public int nrOfIndentSpace = 2;
39+
40+
public boolean indentBlankLines = false;
41+
42+
public boolean indentSchemaLocation = false;
43+
44+
public String indentAttribute = null;
45+
46+
public String predefinedSortOrder = "recommended_2008_06";
47+
48+
public boolean quiet = false;
49+
50+
public String sortOrderFile = null;
51+
52+
public String sortDependencies = null;
53+
54+
public String sortDependencyManagement = null;
55+
56+
public String sortDependencyExclusions = null;
57+
58+
public String sortPlugins = null;
59+
60+
public boolean sortProperties = false;
61+
62+
public boolean sortModules = false;
63+
64+
public boolean sortExecutions = false;
65+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright 2021-2024 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.diffplug.spotless.pom;
17+
18+
import java.io.Serializable;
19+
20+
// Class and members must be public, otherwise we get failed to access class com.diffplug.spotless.pom.SortPomInternalState from class com.diffplug.spotless.pom.SortPomFormatterFunc (com.diffplug.spotless.pom.SortPomInternalState is in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @682bd3c4; com.diffplug.spotless.pom.SortPomFormatterFunc is in unnamed module of loader com.diffplug.spotless.pom.DelegatingClassLoader @573284a5)
21+
public class SortPomCfg implements Serializable {
22+
private static final long serialVersionUID = 1L;
23+
24+
public String version = "4.0.0";
25+
26+
public String encoding = "UTF-8";
27+
28+
public String lineSeparator = System.getProperty("line.separator");
29+
30+
public boolean expandEmptyElements = true;
31+
32+
public boolean spaceBeforeCloseEmptyElement = false;
33+
34+
public boolean keepBlankLines = true;
35+
36+
public boolean endWithNewline = true;
37+
38+
public int nrOfIndentSpace = 2;
39+
40+
public boolean indentBlankLines = false;
41+
42+
public boolean indentSchemaLocation = false;
43+
44+
public String indentAttribute = null;
45+
46+
public String predefinedSortOrder = "recommended_2008_06";
47+
48+
public boolean quiet = false;
49+
50+
public String sortOrderFile = null;
51+
52+
public String sortDependencies = null;
53+
54+
public String sortDependencyManagement = null;
55+
56+
public String sortDependencyExclusions = null;
57+
58+
public String sortPlugins = null;
59+
60+
public boolean sortProperties = false;
61+
62+
public boolean sortModules = false;
63+
64+
public boolean sortExecutions = false;
65+
}

0 commit comments

Comments
 (0)