Correct this "&" to "&&" is sometimes dangerous advice.
if (nullable != null & nullable.length() > 0) print("exists and not empty (must use short circuit with && to avoid NPE)");but
if (youMustCallMe() & youMustCallMe2()) print("called you both successfully (short circuit with && would be wrong)");
Short-circuit logic "should" be used in boolean contexts (squid:S2178). Not always!
--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/bb268e1f-3214-4425-a7e9-f3866ba03fe3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
final boolean callMeResult = youMustCallMe();
final boolean callMe2Result = youMustCallMe2();
if (callMeResult && callMe2Result) {
//do your work here
}
--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/cb9ac0bb-f315-4320-b80b-fdce98499dc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tibor Blenessy | SonarSource
SonarJava Developer