<div dir="ltr">I'm not an expert on lint by any means, but your proposed syntax is not obvious to me, since we can already comma separate warnings to enable and disable them separately. So, with the current syntax, "-Xlint:foobar,unnecessary" would read as: Enable "foobar" warnings, Enable "unnecessary" warnings. Maybe you meant to say that the definition of "unnecessary" flag would be: Print warnings for unnecessary usage of enabled warnings? That is not exactly "precise" though, because in that case I can't say that "Don't report warnings for foobar, but report unnecessary usage of it" (not that this would be terribly useful).<div><br></div><div>Only slightly related, but what I would like to see with -Xlint is a selective "-Werror". That is, fail only on specific warnings, which I would set to fail on every warning, but "deprecated" (because "deprecated" warnings normally appear without you introducing the issue). In fact, my specific pain is that I can't set error prone (or whatever else) to fail on "rawtype", because they are saying it is the responsibility of javac, but then I can't make javac fail on it unless I turn off "deprecated" warnings (which I don't want to turn off).</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Archie Cobbs <<a href="mailto:archie.cobbs@gmail.com">archie.cobbs@gmail.com</a>> ezt írta (időpont: 2023. okt. 7., Szo, 0:41):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I had an idea for a new lint warning and wanted to get feedback from those who understand the lint system better than me about the idea and whether this is feasible.<br></div><div><br></div><div>The name of the new warning would be something like <span style="font-family:monospace">"unnecessary"<font face="arial,sans-serif">.</font></span></div><div><span style="font-family:monospace"><font face="arial,sans-serif"><br></font></span></div><div>The idea is that if you said <span style="font-family:monospace">-Xlint:foobar,unnecessary</span> then you would get a warning for any unnecessary <span style="font-family:monospace">@SuppressWarnings("foobar")</span> annotations, meaning, there are actually no warnings that need suppressing at that spot, and so the annotation is unnecessary and can be removed.</div><div><br></div><div>The reason you would need to do <span style="font-family:monospace">-Xlint:foobar,unnecessary</span><font face="arial,sans-serif"> instead of just plain </font><span style="font-family:monospace">-Xlint:unnecessary<font face="arial,sans-serif"> to cover all of them is because in some cases if </font>-Xlint:foobar<font face="arial,sans-serif"> is not specified then the logic for detecting </font>foobar<font face="arial,sans-serif"> warnings is completely disabled, so it's not possible to know when the warning would or would not have fired. Also, this makes the control more precise.<br></font></span></div><div><br></div><div>The benefit of this of course is it helps avoid accidental warning suppression (false negatives) by making it easier to minimize your suppression surface.<br></div><div><br></div><div>I started trying to evaluate doing this, but am not completely understanding how lint and "deferred lint" interact.</div><div><br></div><div>Is there a lint expert who can comment on whether this would be feasible given the way lint is currently implemented?<br></div><div><br></div><div>Thanks,</div><div>-Archie<br></div><div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div></div>
</blockquote></div>