Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation rule stopped working after upgrading to version 1.10.0 #2970

Closed
keymusicman opened this issue Aug 14, 2020 · 7 comments · Fixed by #4551
Closed

Indentation rule stopped working after upgrading to version 1.10.0 #2970

keymusicman opened this issue Aug 14, 2020 · 7 comments · Fixed by #4551

Comments

@keymusicman
Copy link
Contributor

Expected Behavior

In our project we have Indentation rule turned on with the following rule settings:

  Indentation:
    active: true
    autoCorrect: true
    indentSize: 2
    continuationIndentSize: 4

It is done in accord with our project settings:
image

It worked prior to version 1.10.0

Observed Behavior

We tried upgrading detekt to version 1.10.0 and got 13k errors related to Indentation rule. It says we have wrong indent and the auto correction turned on tries to reformat the code.

The example code that fails Indentation rule after upgrading:

  override fun getAddresses() = async {
    addressRepository.getAll()
        .toVO { address -> address.id == id }
  }

Detekt says that the problem is on the line .toVO { address -> address.id == id }

I know that the new version of KtLint now uses a new Indentation rule that was in experimental state earlier, but I found no mentions that something should break and no guidelines on how to fix it.

Your Environment

  • Version of detekt used: 1.10.0
  • Version of Gradle used (if applicable): 6.4
  • Operating System and version: MacOSX 10.15.4 Catalina
  • Link to your project (if it's a public repository): -
@cortinico
Copy link
Member

We tried upgrading detekt to version 1.10.0 and got 13k errors related to Indentation rule. It says we have wrong indent and the auto correction turned on tries to reformat the code.

I know that the new version of KtLint now uses a new Indentation rule that was in experimental state earlier, but I found no mentions that something should break and no guidelines on how to fix it.

As you said, you're not alone: pinterest/ktlint#764

The current workaround is either to:

  • Disable the Indentation rule at all.
  • Disable the Indentation rule at all + upgrade detekt and run an older version of ktlint that uses the old indentation rule.
  • Don't upgrade and wait for an updated version of KtLint + an updated version of Detekt.

@schalkms
Copy link
Member

Shall we close this issue then in order to not have a duplicate?

@keymusicman
Copy link
Contributor Author

Yes, it can be closed. As the problem is actually related to KtLint, i will follow its ticket (thanks @cortinico !)

@keymusicman
Copy link
Contributor Author

The issue seems should be fixed in KtLint 0.41. I've just upgraded to Detekt 1.19.0 that uses KtLint 0.42.1 and got the same issue - still does not work

@schalkms schalkms reopened this Nov 30, 2021
@cortinico
Copy link
Member

still does not work

Can you provide a reproducer?

@calvarez-ov
Copy link

Here's a bug reproduction project: https://github.com/libon/DetektIndentationIssue

@cortinico
Copy link
Member

Thanks for the reproducer @calvarez-ov
Turns out that KtLint removed the continuation_indent_size in a older version. See:

Therefore we need to deprecate the following config as it's not taken into account by KtLint at all:

@Configuration("continuation indentation size")
private val continuationIndentSize by config(4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants