You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/03/27 15:45:00 UTC
[jira] [Commented] (LUCENE-9878) enable redundantNullCheck in
ecjLint
[ https://issues.apache.org/jira/browse/LUCENE-9878?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17309974#comment-17309974 ]
ASF subversion and git services commented on LUCENE-9878:
---------------------------------------------------------
Commit 3596e05e5cb7c0641f82300e6ed4d091eab0fdd0 in lucene's branch refs/heads/main from Robert Muir
[ https://gitbox.apache.org/repos/asf?p=lucene.git;h=3596e05 ]
LUCENE-9878: enable redundantNullCheck in ecjLint (#44)
Detects common cases of unreachable/dead code.
For generated javacc code, the check is disabled via
SuppressWarnings("unused") because javacc generates strange/bad code such as:
if ("" == null)
For TestStressNRTReplication's startNode() method, the check is also
disabled because analysis folds the "test evilness controls" which are
static final constants. This itself is a WTF, shouldn't we instead
randomize these evil things in our tests rather than hardcoding them to
specific values?
> enable redundantNullCheck in ecjLint
> ------------------------------------
>
> Key: LUCENE-9878
> URL: https://issues.apache.org/jira/browse/LUCENE-9878
> Project: Lucene - Core
> Issue Type: Task
> Reporter: Robert Muir
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Don't be confused by the name, this isn't enabling annotation-based null analyzer or discouraging safety checks in the code.
> This is simple flow analysis to detect cases like the following:
> {code}
> foo = null;
> if (foo != null) {
> // provably dead code
> }
> {code}
> {code}
> foo.invokeMethod();
> if (foo != null) {
> // provably dead code, would have thrown exc
> }
> {code}
> I reviewed all the errors, and the check seems productive. I think a lot of this stuff happens as the code "ages" over time. Lots of WTFs :) It even found what appears to be a seriously broken equals() implementation.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org