Skip to content

Commit 52cd07d

Browse files
committed
Rename RemoveWildcardImports to ForbidWildcardImports in maven.
1 parent 792d0f2 commit 52cd07d

File tree

5 files changed

+44
-52
lines changed

5 files changed

+44
-52
lines changed

plugin-maven/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ any other maven phase (i.e. compile) then it can be configured as below;
230230
</importOrder>
231231

232232
<removeUnusedImports /> <!-- self-explanatory -->
233-
<removeWildcardImports /> <!-- drop any import ending with '*' -->
233+
<forbidWildcardImports /> <!-- yell if any import ends with '*' -->
234234

235235
<formatAnnotations /> <!-- fixes formatting of type annotations, see below -->
236236

@@ -249,10 +249,10 @@ any other maven phase (i.e. compile) then it can be configured as below;
249249
</removeUnusedImports>
250250
```
251251

252-
### removeWildcardImports
252+
### forbidWildcardImports
253253

254254
```xml
255-
<removeWildcardImports/>
255+
<forbidWildcardImports/>
256256
```
257257

258258
### google-java-format
@@ -1950,7 +1950,7 @@ Sometimes Spotless will encounter lint errors that can't be auto-fixed. For exam
19501950

19511951
```
19521952
[ERROR] Unable to format file src/main/java/com/example/App.java
1953-
[ERROR] Step 'removeWildcardImports' found problem in 'App.java':
1953+
[ERROR] Step 'forbidWildcardImports' found problem in 'App.java':
19541954
[ERROR] Do not use wildcard imports
19551955
```
19561956

@@ -1963,12 +1963,12 @@ To suppress these lints, you can use the `<lintSuppressions>` configuration:
19631963
<version>${spotless.version}</version>
19641964
<configuration>
19651965
<java>
1966-
<removeWildcardImports/>
1966+
<forbidWildcardImports/>
19671967
</java>
19681968
<lintSuppressions>
19691969
<lintSuppression>
19701970
<path>src/main/java/com/example/App.java</path>
1971-
<step>removeWildcardImports</step>
1971+
<step>forbidWildcardImports</step>
19721972
<shortCode>*</shortCode>
19731973
</lintSuppression>
19741974
</lintSuppressions>
@@ -1988,13 +1988,13 @@ You can suppress multiple patterns:
19881988
<!-- Suppress all wildcard import errors in legacy code -->
19891989
<lintSuppression>
19901990
<path>src/main/java/com/example/legacy/*</path>
1991-
<step>removeWildcardImports</step>
1991+
<step>forbidWildcardImports</step>
19921992
<shortCode>*</shortCode>
19931993
</lintSuppression>
19941994
<!-- Suppress all errors from a specific step -->
19951995
<lintSuppression>
19961996
<path>*</path>
1997-
<step>removeWildcardImports</step>
1997+
<step>forbidWildcardImports</step>
19981998
<shortCode>*</shortCode>
19991999
</lintSuppression>
20002000
</lintSuppressions>

plugin-maven/src/main/java/com/diffplug/spotless/maven/java/RemoveWildcardImports.java renamed to plugin-maven/src/main/java/com/diffplug/spotless/maven/java/ForbidWildcardImports.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.diffplug.spotless.maven.FormatterStepConfig;
2121
import com.diffplug.spotless.maven.FormatterStepFactory;
2222

23-
public class RemoveWildcardImports implements FormatterStepFactory {
23+
public class ForbidWildcardImports implements FormatterStepFactory {
2424
@Override
2525
public FormatterStep newFormatterStep(FormatterStepConfig config) {
2626
return RemoveWildcardImportsStep.create();

plugin-maven/src/main/java/com/diffplug/spotless/maven/java/Java.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public void addRemoveUnusedImports(RemoveUnusedImports removeUnusedImports) {
7676
addStepFactory(removeUnusedImports);
7777
}
7878

79-
public void addRemoveWildcardImports(RemoveWildcardImports removeWildcardImports) {
80-
addStepFactory(removeWildcardImports);
79+
public void addRemoveWildcardImports(ForbidWildcardImports forbidWildcardImports) {
80+
addStepFactory(forbidWildcardImports);
8181
}
8282

8383
public void addFormatAnnotations(FormatAnnotations formatAnnotations) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2025 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.maven.java;
17+
18+
import org.junit.jupiter.api.Test;
19+
20+
import com.diffplug.spotless.maven.MavenIntegrationHarness;
21+
22+
class ForbidWildcardImportsStepTest extends MavenIntegrationHarness {
23+
24+
@Test
25+
void testRemoveWildcardImports() throws Exception {
26+
writePomWithJavaSteps("<removeWildcardImports/>");
27+
28+
String path = "src/main/java/test.java";
29+
setFile(path).toResource("java/removewildcardimports/JavaCodeWildcardsUnformatted.test");
30+
mavenRunner().withArguments("spotless:apply").runNoError();
31+
assertFile(path).sameAsResource("java/removewildcardimports/JavaCodeWildcardsFormatted.test");
32+
}
33+
}

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

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)