Skip to content

Conversation

Stephan202
Copy link
Contributor

Resolves #4943.

Copy link
Contributor Author

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some context.

ImmutableSet<String> disabled =
getAllChecks().values().stream()
.filter(predicate.negate())
.filter(bci -> disabled().contains(bci.canonicalName()) || !predicate.test(bci))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";
}
""");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@CRogers
Copy link

CRogers commented Jun 16, 2025

Thanks for the fix!

@CRogers
Copy link

CRogers commented Sep 12, 2025

Would it be possible to merge this fix?

@TotallyMehis
Copy link

+1

This is particularly annoying, would love to see this merged.

copybara-service bot pushed a commit that referenced this pull request Sep 19, 2025
Resolves #4943.

Fixes #5102

FUTURE_COPYBARA_INTEGRATE_REVIEW=#5102 from PicnicSupermarket:sschroevers/have-XepPatchChecks-skip-disabled-checks dabd820
PiperOrigin-RevId: 808396119
@Stephan202 Stephan202 deleted the sschroevers/have-XepPatchChecks-skip-disabled-checks branch September 19, 2025 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v2.37.0] Disabled checks are executed when XepPatchChecks: is empty
4 participants