- Notifications
You must be signed in to change notification settings - Fork 486
allow ReplaceRegexStep
to function as a Linter, use that to improve RemoveWildcardImports
#2571
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
Merged
nedtwigg merged 22 commits into diffplug:main from iddeepak:fix-RemoveWildcardImportsStep Sep 23, 2025
Merged
Changes from all commits
Commits
Show all changes
22 commits Select commit Hold shift + click to select a range
a93a424
removeWildcardImports: throw new AssertionError instead of removing
b846b0b
removeWildcardImports: throw new AssertionError instead of removing
730f211
Update lib/src/main/java/com/diffplug/spotless/java/RemoveWildcardImp…
Pankraz76 43adf9e
Merge remote-tracking branch 'f/fix-RemoveWildcardImportsStep' into f…
777f496
removeWildcardImports: throw new AssertionError instead of removing
0956a48
removeWildcardImports: throw new AssertionError instead of removing
350b8a4
wip
e13b9b0
Fix lint
iddeepak 1cb31dd
spotless-apply
iddeepak 0f95d2f
lib-spotless-apply
iddeepak 362502a
use lint-errors
iddeepak c4f0150
Merge branch 'diffplug:main' into fix-RemoveWildcardImportsStep
iddeepak 04e40ff
no lint-errors for maven spotless-apply
iddeepak c0cf2da
undo changes
iddeepak b331249
Merge branch 'diffplug:main' into fix-RemoveWildcardImportsStep
iddeepak 9042049
undo changes
iddeepak 8999fb2
undo changes
iddeepak 2cc47d2
Merge branch 'main' into fix-RemoveWildcardImportsStep
nedtwigg a6b7d52
Update changelog.
nedtwigg a83807f
Make `ReplaceRegexStep` a bit more idiomatically a linter.
nedtwigg 31302c8
Improve error messages.
nedtwigg 7140dcd
Merge branch 'main' into fix-RemoveWildcardImportsStep
nedtwigg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions 4 testlib/src/main/resources/java/removewildcardimports/JavaCodeNoWildcardsFormatted.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import java.util.List; | ||
import mylib.Helper; | ||
| ||
public class Test {} |
4 changes: 4 additions & 0 deletions 4 testlib/src/main/resources/java/removewildcardimports/JavaCodeNoWildcardsUnformatted.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import java.util.List; | ||
import mylib.Helper; | ||
| ||
public class Test {} |
5 changes: 5 additions & 0 deletions 5 testlib/src/main/resources/java/removewildcardimports/JavaCodeWildcardsFormatted.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import java.util.*; | ||
import static java.util.Collections.*; | ||
import java.util.List; | ||
import mylib.Helper; | ||
import io.quarkus.maven.dependency.*; | ||
import static io.quarkus.vertx.web.Route.HttpMethod.*; | ||
import static org.springframework.web.reactive.function.BodyInserters.*; | ||
| ||
public class Test {} |
44 changes: 44 additions & 0 deletions 44 testlib/src/test/java/com/diffplug/spotless/generic/ReplaceRegexStepTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2025 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.diffplug.spotless.generic; | ||
| ||
import org.junit.jupiter.api.Test; | ||
| ||
import com.diffplug.common.base.StringPrinter; | ||
import com.diffplug.spotless.FormatterStep; | ||
import com.diffplug.spotless.StepHarness; | ||
| ||
class ReplaceRegexStepTest { | ||
@Test | ||
void formatter() throws Exception { | ||
FormatterStep step = ReplaceRegexStep.create("replace", "bad", "good"); | ||
StepHarness.forStep(step) | ||
.test("bad bad", "good good"); | ||
} | ||
| ||
@Test | ||
void lint() throws Exception { | ||
FormatterStep step = ReplaceRegexStep.lint("stayPositive", "(bad|awful)", "no negative words"); | ||
StepHarness.forStep(step) | ||
.expectLintsOf(StringPrinter.buildStringFromLines( | ||
"bad", | ||
"oh boy", | ||
"x awful y", | ||
"yippeee")) | ||
.toBe("L1 stayPositive(bad) no negative words", | ||
"L3 stayPositive(awful) no negative words"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nedtwigg
spotless:apply for maven does not show lint errors ? for gradle it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha! you are correct! i will try to fix that problem this week...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it resolved so we can continue, or is the issue bigger than expected?