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

Check extra whitespace success, but check extra tab character in the begin of line does not work #425

Closed
ElenaSpb opened this issue May 13, 2019 · 9 comments · Fixed by #1031

Comments

@ElenaSpb
Copy link

ElenaSpb commented May 13, 2019

gradle task ktlint failed if there are extra whitespaces with
error line="9" column="1" severity="error" message="Unexpected indentation (11) (it should be 8) (cannot be auto-corrected)" source="indent"
for example.

but if there are extra tab character in the begining of line - the task finish success, which is not expected.

@shashachu
Copy link
Contributor

@ElenaSpb can you give a small code snippet demonstrating the issue? Thanks!

@shashachu shashachu added the bug label May 23, 2019
@realdadfish
Copy link

I'm not sure if this is related, but this code snippet does not provoke an error in KtLint, which it should:

class Foo {
    private fun doBar(): Int =
        if (somethingIsTrue) {
            doThis()
    } else {
        doThat()
    }
    ...
}

Notice how the indentation of the else block is not following the one of the if block. This is with ktlint 0.34.2 btw. and was also the case with 0.31 and earlier versions before.

@alejandrorosas
Copy link

alejandrorosas commented Sep 23, 2019

@realdadfish I think he means this case:

class Foo {
    private fun doBar() {
            doThis()
    }

    private fun doFoo() {
        doThis()
    }
    ...
}

So this case it succeeds when linting although there's an extra tab on the doBar() method.

@ElenaSpb
Copy link
Author

ElenaSpb commented Sep 23, 2019

additionally - if package in class is not the same as location - it does not show such errors..

@ggajews
Copy link

ggajews commented Oct 9, 2019

@ElenaSpb I run into the same issue. How did you change the configuration to fix this?

@Tapchicoma
Copy link
Collaborator

@ggajews is it happening for you as well?

@ElenaSpb
Copy link
Author

ElenaSpb commented Oct 11, 2019

execuse me - I thought I leave previos comment (about fixing with configuration) in another issue.
this 2 bugs which I describe are still reproduced
may be there were made some changes
but in
ktlint "com.github.shyiko:ktlint:0.31.0"
it is reproduces

@ElenaSpb ElenaSpb reopened this Oct 11, 2019
@ggajews
Copy link

ggajews commented Oct 15, 2019

@Tapchicoma yes, we are using spaces for formatting, and if I add a random tab in the line, ktlint does not report it.

@paul-dingemans
Copy link
Collaborator

Problem is that lines that are properly indented at the correct level but are using the wrong indentation style (tabs instead of space or vice versa) are not autocorrected. In the example of this issue, only the the improperly indented lines were fixed. PR is on its way.

paul-dingemans pushed a commit to paul-dingemans/ktlint that referenced this issue Dec 25, 2020
romtsn pushed a commit that referenced this issue Dec 25, 2020
…g indentation style (#425) (#1031)

Co-authored-by: Paul Dingemans <pdingemans@bol.com>
romtsn pushed a commit to paul-dingemans/ktlint that referenced this issue Mar 7, 2021
…g indentation style (pinterest#425) (pinterest#1031)

Co-authored-by: Paul Dingemans <pdingemans@bol.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants