Open nfsantos opened 7 years ago
With version 0.1.17, I get a false positive with the following code:
def test1(s: StringBuilder): Boolean = { if (s != null) { val trimmed = s.toString.trim trimmed.nonEmpty } else { false } }
Warning:(123, 15) [UnnecessaryStringNonEmpty] This string will never be empty. trimmed.nonEmpty
If I remove the intermediate variable trimmed, the false positive disappears:
trimmed
def test2(s: StringBuilder): Boolean = { if (s != null) { s.toString.trim.nonEmpty } else { false } }
It is also not reported if we replace StringBuilder by String as the argument:
def test3(s: String): Boolean = { if (s != null) { val trimmed = s.trim trimmed.nonEmpty } else { false } }
With version 0.1.17, I get a false positive with the following code:
If I remove the intermediate variable
trimmed
, the false positive disappears:It is also not reported if we replace StringBuilder by String as the argument: