Skip to content
New issue

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

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

Already on GitHub? # to your account

Indentation is not flagged correctly when using use #141

Closed
vanniktech opened this issue Jan 25, 2018 · 5 comments
Closed

Indentation is not flagged correctly when using use #141

vanniktech opened this issue Jan 25, 2018 · 5 comments

Comments

@vanniktech
Copy link
Contributor

I'm in a 2 spaces project with the following code.

class ReaderFacade {
  fun run() {
    val output: Output = CsvOutput()

    Okio.buffer(Okio.sink(File("output.${output.fileEnding}"))).use {
        it.writeUtf8(stringOutput)
      }
  }
}

I'd expect it to get flagged since the line in use as well as the } is not indented correctly. Instead it should look like this:

-        it.writeUtf8(stringOutput)
-      }
+      it.writeUtf8(stringOutput)
+    }

I'm running version 0.15.0. Didn't try the snapshot out as it should only add quick fixing in case it gets reported. Correct me if I'm wrong.

@MyDogTom
Copy link
Contributor

MyDogTom commented Jan 29, 2018

This is due to two "limitations" of IndentionRule

  1. Rule expects that there is always an indent. Regular one or continuation. In that case, there is no indent at all. Of course, there is "parent indent" for entire block, but inside that block, there is no additional indent for }
  2. Rule is not strict enough in detecting violations. There is condition used
    (line.length - previousIndent) % expectedIndentSize != 0
    As result, not all violations are detected. This is also a reason why rule doesn't fail everywhere for }.

Ideally, I'd like to make condition more strict (line.length - previousIndent) != expectedIndentSize. But for that we have to teach rule about all other elements (} etc).

I'm happy to work on that, but it will take some time.

@Octogonapus
Copy link

Have there been any updates on this issue?

@MyDogTom
Copy link
Contributor

@Octogonapus Sorry, I didn't really made any progress here. But I'm still interested in that topic. Hopefully, I'll be able to come back soon.

@Octogonapus
Copy link

Ok. Let me know if there is something I can do to help.

@shyiko
Copy link
Collaborator

shyiko commented Feb 11, 2019

Moved to #338.

@shyiko shyiko closed this as completed Feb 11, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants