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

Unexpected indentation (expected 8, actual 12) #558

Closed
mnewlive opened this issue Aug 7, 2019 · 6 comments
Closed

Unexpected indentation (expected 8, actual 12) #558

mnewlive opened this issue Aug 7, 2019 · 6 comments

Comments

@mnewlive
Copy link

mnewlive commented Aug 7, 2019

Have next code:

interface BiometricPromptAbs {

    var resultCallback: BiometricPromptCallback?
    fun showBiometricPrompt(
            context: FragmentActivity,
            @StringRes titleResId: ResId,
            @StringRes descriptionResId: ResId,
            @StringRes negativeActionTextResId: ResId
    )
}

Specifies the same error for all four parameters:

Unexpected indentation (expected 8, actual 12)

I tried to configure the project as shown here and here
But the error remained.

Some code from my root build.gradle:

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        jcenter()
        google()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
        gradlePluginPortal()
    }
dependencies { 
        classpath "org.jlleitschuh.gradle:ktlint-gradle:8.2.0"
    }

subprojects {
    apply plugin: "org.jlleitschuh.gradle.ktlint" // Version should be inherited from parent

    // Optionally configure plugin
    ktlint {
        debug = true
    }

    dependencies {
        ktlintRuleset project(':ktlint_rules')
    }
}
@mnewlive
Copy link
Author

mnewlive commented Aug 7, 2019

codeStyle

Use this settings, and use 4 in field Continuation indent:

codeStyle2
Everything seems to work, but I'm sure it will be right 🤔 😉

@imGurpreetSK
Copy link

imGurpreetSK commented Aug 21, 2019

Also, if the indentation of a line is more than the required one, but in multiples of the set indentation value, ktlint fails to report an error.

Example:
An error will be reported in this case:

override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState) // 10 spaces indent
        setContentView(R.layout.main_activity)
}

but not in this case:

override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState) // 12 spaces indent, should be 8 ideally.
        setContentView(R.layout.main_activity)
}

@lxdraw
Copy link

lxdraw commented Jan 3, 2020

I am seeing the same issue as @GurpreetSK95. When a continuation indent is any multiple of the indent size it passes validation.

fun findById(id: String): Mono<Thing> =
        databaseClient
                                    .execute(SqlStatements.findById)
            .bind("id", id)
            .map(Thing::map)
            .first()

I think this should count as a violation.

@christianhujer
Copy link

To me, this is a bug in ktlint.
IntelliJ IDEA Ultimate Edition default settings should be regarded as correct, they are "from the creators".

@romtsn
Copy link
Collaborator

romtsn commented Aug 16, 2020

@lxdraw @imGurpreetSK this should be fixed already - please use the latest version.
@mnewlive let's track this in #805 - I've filed an issue on JB's side, hopefully we'll get some guidance

@romtsn romtsn closed this as completed Aug 16, 2020
@Pirokar
Copy link

Pirokar commented Aug 29, 2023

image
The same bug

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

No branches or pull requests

7 participants