Deduplicate Java runtime mismatch hints per formatter invocation#283
Merged
Deduplicate Java runtime mismatch hints per formatter invocation#283
Conversation
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.
Summary
This adjusts the Java runtime mismatch hint deduplication logic so it is scoped to a single formatter invocation, instead of effectively sticking for the whole sbt session.
Problem
After
the hint was logged only once per project, which reduced the noise during a single
javafmtAllrun.However, that also meant that if a user stayed in the same sbt session and ran
javafmtAllagain later, the hint would no longer be shown at all for projects that had already logged it once before.That is not what we want. The hint should be deduplicated within one formatter run, but it should appear again for a later independent run.
Change
Instead of resetting mutable state at task entry, this PR introduces an internal formatter invocation id:
javafmt,javafmtCheck,javafmtFixImports, andjavafmtFixImportsCheckinvocation gets a fresh internal idThis keeps the good behavior from
#282:javafmtAlldoes not spam the same hint repeatedly within one runwhile restoring the missing behavior:
javafmtAllagain later in the same sbt session shows the hint againUser-visible behavior
With an incompatible formatter JVM:
javafmtAllrun logs the hint once per affected projectjavafmtAllrun in the same sbt session logs the hint againjavafmt/javafmtCheckruns also behave the same wayVerification
Tested locally by publishing the plugin and reproducing the behavior in a multi-project build:
javafmtAllrun: hint shown once per affected projectjavafmtAllrun in the same sbt session: hint shown again