RFR: 8345263: Make sure that lint categories are used correctly when logging lint warnings [v2]
Archie Cobbs
acobbs at openjdk.org
Thu Dec 5 15:23:40 UTC 2024
On Thu, 5 Dec 2024 14:34:29 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> we probably need something that will avoid running the lint's code completely in a (semi-)automatic way. That could be part of a more generic 22088.
Agreed.
Slight comment hijack follows...
The [unnecessary suppression warning proposal](https://mail.openjdk.org/pipermail/compiler-dev/2024-November/028573.html) would create a natural answer for this, because there would be a new concept "active" along with "enabled": A category is active if it's enabled OR we are tracking unnecessary suppressions, the category is being suppressed at this point in the code, and so far that suppression is unnecessary (i.e., no warnings would have fired yet).
So linter code would want to check for "active" status (instead of "enabled" status) before doing a non-trivial calculation, which would end up looking like this:
if (lint.isActive(LintCategory.FOO) &&
complicatedCalculationA() &&
complicatedCalculationB()) {
lint.logIfEnabled(log, pos, LintWarnings.FooProblem);
}
But perhaps then we should then consider lambda-ification, which would simplify this down to:
lint.check(log, pos, LintWarnings.FooProblem,
() -> complicatedCalculationA() && complicatedCalculationB());
This could be your "(semi-)automatic" option.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22553#discussion_r1871579738
More information about the build-dev
mailing list