Detekt: False positive in `Indentation` if block

Created on 13 Aug 2020  路  3Comments  路  Source: detekt/detekt


Expected Behavior


When I run detekt-formatting, Indentation formats differently from Intellij in this case

Observed Behavior


Indentation after if block has disappeared

Steps to Reproduce



Before formatting

if (holder.type == TYPE_FLAG)
    (holder as HolderA).functionA()
else
    (holder as HolderB).functionB()

After formatting

if (holder.type == TYPE_FLAG)
(holder as HolderA).functionA()
else
(holder as HolderB).functionB()

Context



Doesn't match Intellij, so diff keeps happening

I confirmed that this works fine with MultiLineIfElse, Unfortunately, my team has decided not to use MultiLineIfElse.

This is part of my config.yml

formatting:
  NoWildcardImports:
    active: false
  ImportOrdering:
    active: false
  NoConsecutiveBlankLines:
    active: false
  MultiLineIfElse:
    active: false

Your Environment

  • Version of detekt used: 1.10.0, I also tested with 1.11.0-RC2
formatting

Most helpful comment

Thanks for checking this in plain ktlint. I will close this for now, since this issue is already tracked in the main ktlint repo.

All 3 comments

Hey @zmunm! Thanks for reporting this.
detekt-formatting wraps ktlint's ruleset. Can you please try this out with plain ktlint?
If this issue occurs with standalone ktlint, may I ask you to please report this to their main repository, since there's nothing detekt can do about.

Thank you for your quick response. I will try it

Thanks for checking this in plain ktlint. I will close this for now, since this issue is already tracked in the main ktlint repo.

Was this page helpful?
0 / 5 - 0 ratings