Have -XepPatchChecks: skip disabled checks#5102
Closed
Stephan202 wants to merge 1 commit intogoogle:masterfrom
Closed
Have -XepPatchChecks: skip disabled checks#5102Stephan202 wants to merge 1 commit intogoogle:masterfrom
-XepPatchChecks: skip disabled checks#5102Stephan202 wants to merge 1 commit intogoogle:masterfrom
Conversation
Stephan202
commented
Jun 14, 2025
| ImmutableSet<String> disabled = | ||
| getAllChecks().values().stream() | ||
| .filter(predicate.negate()) | ||
| .filter(bci -> disabled().contains(bci.canonicalName()) || !predicate.test(bci)) |
Contributor
Author
There was a problem hiding this comment.
The changes in #4699 assumed that ScannerSupplier#filter would merely disable additional checks, but in fact it could re-enable disabled checks. This change proposes to resolve that, yielding more intuitive semantics.
Comment on lines
+489
to
+513
| @Test | ||
| public void patchAllWithDisableAllChecks() throws IOException { | ||
| JavaFileObject fileObject = | ||
| createOnDiskFileObject( | ||
| "StringConstantWrapper.java", | ||
| """ | ||
| class StringConstantWrapper { | ||
| String s = "old-value"; | ||
| } | ||
| """); | ||
|
|
||
| CompilationResult result = | ||
| doCompile( | ||
| Collections.singleton(fileObject), | ||
| Arrays.asList("-XepPatchChecks:", "-XepPatchLocation:IN_PLACE", "-XepDisableAllChecks"), | ||
| ImmutableList.of(AssignmentUpdater.class)); | ||
| assertThat(result.succeeded).isTrue(); | ||
| assertThat(Files.readString(Path.of(fileObject.toUri()))) | ||
| .isEqualTo( | ||
| """ | ||
| class StringConstantWrapper { | ||
| String s = "old-value"; | ||
| } | ||
| """); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This new test fails prior to the proposed changes. Observe that the only difference with the preceding patchAllWithCheckDisabled test is the use of -XepDisableAllChecks instead of -Xep:AssignmentUpdater:OFF.
cushon
approved these changes
Jun 15, 2025
|
Thanks for the fix! |
|
Would it be possible to merge this fix? |
|
+1 This is particularly annoying, would love to see this merged. |
cushon
approved these changes
Sep 18, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #4943.