Skip to content

detekt wants different indentation than ktlint #519

@kts2

Description

@kts2

Expected Behavior

Detekt and ktlint should push for the same indentation.

Observed Behavior

In the attached example detekt wants 12, while ktlint wants 16.
So one of these linters will complain, always.

Steps to Reproduce

  1. Enable File > Settings > Tools > detekt > Rules > Enable formatting (ktlint) rules in AndroidStudio
  2. Write code like
@Composable
fun Example(
    icon: Painter,
    text: String,
    modifier: Modifier = Modifier,
) {
    Row(
        modifier =
        modifier //!!
            .fillMaxWidth() //!!
            .height(50.dp), //!!
        verticalAlignment = Alignment.CenterVertically,
    ) {...}}
  1. The lines marked above with //!! will be reported with bad indentation. If one tool (e.g. ktlint) is allowed to fix the indentation, the other (e.g. detekt) starts complaining and vice versa:

detekt-16to12
ktlint-12to16

Context

I want a warning free code, both from ktlint and detekt.

Your Environment

  • Version of detekt used: detekt plugin (in Android Studio): 2.4.1
  • ktlint plugin (in AS): 0.24.1
  • Version of Gradle used (if applicable): 8.5; Android Gradle plugin: 8.2.2
  • Gradle scan link (add --scan option when running the gradle task): n/a
  • Operating System and version: Ubuntu Linux 22.04
  • Link to your project (if it's a public repository): n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions