== Why is this an issue?

Once a value is known to be ``++null++`` or non-``++null++``, there's no reason to re-check it unless it has been changed (or potentially changed) in the interim. Doing so anyway may may just be an over-abundance of caution, but it could indicate a bug.


=== Noncompliant code example

[source,java]
----
public void assignCoach(Team team, Person person) {

  if (team.hasCoach()) {  // team is dereferenced
    return;
  }

  if (team != null) {  // Noncompliant; if we got this far, team is not null
    //...
  }

  if (person != null) {
    // ...
    if (disqualified) {
      person = getAlternate();
    }
  }

  if (person != null) { // Compliant; person may have changed since last check
    team.setCoach(person);
  }

  if (person != null) {  // Noncompliant; no changes to person since last check
    // ...

----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

=== on 24 Oct 2014, 19:14:41 Ann Campbell wrote:
\[~nicolas.peru] note that I've marked this as covering:

* RCN_REDUNDANT_COMPARISON_OF_NULL_AND_NONNULL_VALUE
* RCN_REDUNDANT_COMPARISON_TWO_NULL_VALUES

My memory is fuzzy on exactly what code triggers these two & it's difficult to tell from the FB code. Please let me know if I got it wrong.

endif::env-github,rspecator-view[]
