HairyFotr / linter

Static Analysis Compiler Plugin for Scala
Apache License 2.0
268 stars 34 forks source link

[false positive] "These two nested ifs can be merged into one" when using if + macro + inline #18

Closed mauhiz closed 9 years ago

mauhiz commented 9 years ago

Say we have a macro for debugging:

@inline def debug(msg: => String): Unit = macro debugImpl

with debugImpl being equivalent to:

if (Logger.isDebugEnabled) Logger.debug(msg)

Then errors are reported on the call sites of this method:

if (someCondition) debug(msg) <<<

HairyFotr commented 9 years ago

I'm guessing it could be that it's not because it's a macro, but because of the @inline, but it's definitely a false positive.

I'll take a closer look later today.

HairyFotr commented 9 years ago

I've published the fix under 0.1-SNAPSHOT (as usual), so just run sbt update, and compile normally, and hopefully this false positive is fixed.

mauhiz commented 9 years ago

@HairyFotr amazing! thanks

HairyFotr commented 9 years ago

Thank you for reporting it!