Skip to content

Commit d6329c5

Browse files
author
Vincent Potucek
committed
use palantir-java-format as default formatter in RemoveUnusedImportsStep
1 parent 2d32ccd commit d6329c5

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2024 DiffPlug
2+
* Copyright 2016-2025 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.
@@ -22,12 +22,12 @@
2222
import com.diffplug.spotless.FormatterStep;
2323
import com.diffplug.spotless.Provisioner;
2424

25-
/** Uses google-java-format or cleanthat.UnnecessaryImport, but only to remove unused imports. */
25+
/** Uses palantir-java-format or cleanthat.UnnecessaryImport, but only to remove unused imports. */
2626
public class RemoveUnusedImportsStep implements Serializable {
2727
private static final long serialVersionUID = 1L;
2828
static final String NAME = "removeUnusedImports";
2929

30-
static final String GJF = "google-java-format";
30+
static final String DEFAULT_FORMATTER = "palantir-java-format";
3131
static final String CLEANTHAT = "cleanthat-javaparser-unnecessaryimport";
3232

3333
// https://github.com/solven-eu/cleanthat/blob/master/java/src/main/java/eu/solven/cleanthat/engine/java/refactorer/mutators/UnnecessaryImport.java
@@ -37,18 +37,17 @@ public class RemoveUnusedImportsStep implements Serializable {
3737
private RemoveUnusedImportsStep() {}
3838

3939
public static String defaultFormatter() {
40-
return GJF;
40+
return DEFAULT_FORMATTER;
4141
}
4242

4343
public static FormatterStep create(Provisioner provisioner) {
44-
// The default importRemover is GJF
45-
return create(GJF, provisioner);
44+
return create(DEFAULT_FORMATTER, provisioner);
4645
}
4746

4847
public static FormatterStep create(String unusedImportRemover, Provisioner provisioner) {
4948
Objects.requireNonNull(provisioner, "provisioner");
5049
switch (unusedImportRemover) {
51-
case GJF:
50+
case DEFAULT_FORMATTER:
5251
return GoogleJavaFormatStep.createRemoveUnusedImportsOnly(provisioner);
5352
case CLEANTHAT:
5453
return CleanthatJavaStep.createWithStepName(NAME, CleanthatJavaStep.defaultGroupArtifact(), CleanthatJavaStep.defaultVersion(), "99.9", List.of(CLEANTHAT_MUTATOR), List.of(), false, provisioner);

testlib/src/test/java/com/diffplug/spotless/java/RemoveUnusedImportsStep_withGoogleJavaFormatTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2025 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.
@@ -25,7 +25,7 @@
2525
class RemoveUnusedImportsStep_withGoogleJavaFormatTest {
2626
@Test
2727
void behavior() throws Exception {
28-
FormatterStep step = RemoveUnusedImportsStep.create(RemoveUnusedImportsStep.GJF, TestProvisioner.mavenCentral());
28+
FormatterStep step = RemoveUnusedImportsStep.create(RemoveUnusedImportsStep.DEFAULT_FORMATTER, TestProvisioner.mavenCentral());
2929
StepHarness.forStep(step)
3030
.testResource("java/removeunusedimports/JavaCodeUnformatted.test", "java/removeunusedimports/JavaCodeFormatted.test")
3131
.testResource("java/removeunusedimports/JavaCodeWithLicenseUnformatted.test", "java/removeunusedimports/JavaCodeWithLicenseFormatted.test")
@@ -48,7 +48,7 @@ protected void setupTest(API api) {
4848

4949
@Override
5050
protected FormatterStep create() {
51-
return RemoveUnusedImportsStep.create(RemoveUnusedImportsStep.GJF, TestProvisioner.mavenCentral());
51+
return RemoveUnusedImportsStep.create(RemoveUnusedImportsStep.DEFAULT_FORMATTER, TestProvisioner.mavenCentral());
5252
}
5353
}.testEquals();
5454
}

0 commit comments

Comments
 (0)