Skip to content

Commit a3c5edb

Browse files
committed
Update Cleanthat to 2.2. Tests workaround lack of OptionalNotEmpty
1 parent 54f692f commit a3c5edb

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/src/main/java/com/diffplug/spotless/java/CleanthatJavaStep.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class CleanthatJavaStep {
4040
private static final String MAVEN_COORDINATE = "io.github.solven-eu.cleanthat:java";
4141

4242
// CleanThat changelog is available at https://github.com/solven-eu/cleanthat/blob/master/CHANGES.MD
43-
private static final Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support(NAME).add(11, "2.1");
43+
private static final Jvm.Support<String> JVM_SUPPORT = Jvm.<String> support(NAME).add(11, "2.2");
4444

4545
// prevent direct instantiation
4646
private CleanthatJavaStep() {}
@@ -71,8 +71,7 @@ public static List<String> defaultExcludedMutators() {
7171
* @return
7272
*/
7373
public static List<String> defaultMutators() {
74-
// see JavaRefactorerProperties.WILDCARD
75-
return List.of("*");
74+
return List.of("eu.solven.cleanthat.engine.java.refactorer.mutators.composite.SafeAndConsensualMutators");
7675
}
7776

7877
/** Creates a step which apply selected CleanThat mutators. */

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,23 @@ class CleanthatJavaRefactorerTest extends MavenIntegrationHarness {
2929
void testLiteralsFirstInComparisons() throws Exception {
3030
writePomWithJavaSteps(
3131
"<cleanthat>",
32+
" <mutators>",
33+
" <mutator>LiteralsFirstInComparisons</mutator>",
34+
" </mutators>",
3235
"</cleanthat>");
3336

3437
runTest("LiteralsFirstInComparisons.dirty.java", "LiteralsFirstInComparisons.clean.java");
3538
}
3639

3740
@Test
3841
void testMultipleMutators_defaultIsJdk7() throws Exception {
42+
// OptionalNotEmpty will be excluded as it is not compatible with JDK7
3943
writePomWithJavaSteps(
4044
"<cleanthat>",
45+
" <mutators>",
46+
" <mutator>LiteralsFirstInComparisons</mutator>",
47+
" <mutator>OptionalNotEmpty</mutator>",
48+
" </mutators>",
4149
"</cleanthat>");
4250

4351
runTest("MultipleMutators.dirty.java", "MultipleMutators.clean.onlyLiteralsFirst.java");
@@ -47,7 +55,11 @@ void testMultipleMutators_defaultIsJdk7() throws Exception {
4755
void testMultipleMutators_Jdk11IntroducedOptionalisPresent() throws Exception {
4856
writePomWithJavaSteps(
4957
"<cleanthat>",
50-
"<sourceJdk>11</sourceJdk>",
58+
" <sourceJdk>11</sourceJdk>",
59+
" <mutators>",
60+
" <mutator>LiteralsFirstInComparisons</mutator>",
61+
" <mutator>OptionalNotEmpty</mutator>",
62+
" </mutators>",
5163
"</cleanthat>");
5264

5365
runTest("MultipleMutators.dirty.java", "MultipleMutators.clean.java");
@@ -57,6 +69,10 @@ void testMultipleMutators_Jdk11IntroducedOptionalisPresent() throws Exception {
5769
void testExcludeOptionalNotEmpty() throws Exception {
5870
writePomWithJavaSteps(
5971
"<cleanthat>",
72+
" <mutators>",
73+
" <mutator>LiteralsFirstInComparisons</mutator>",
74+
" <mutator>OptionalNotEmpty</mutator>",
75+
" </mutators>",
6076
" <excludedMutators>",
6177
" <excludedMutator>OptionalNotEmpty</excludedMutator>",
6278
" </excludedMutators>",

0 commit comments

Comments
 (0)