Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Add ktlint Kotlin linter via Spotless plugin #23

Merged
merged 5 commits into from
Sep 21, 2018
Merged

Conversation

etanshaul
Copy link
Contributor

@etanshaul etanshaul commented Sep 20, 2018

fixes #16

Spotless plugin (used in cloud tools for intellij also) has built in support for ktlint.

There are a few peculiarities that we can iron out as we go along:

  • the IJ formatter doesn't seem to enforce the line length rule (even though the linter will fail since 100 char limit is part of the Android Studio style guide)
  • The current settings can lead to some strange formatting (see the changes to SkaffoldUiResources in this PR). As far as I can tell this is correct Kotlin styling
  • ktlint has some basic auto-formatting limitations: it cannot (yet?) auto-format indentation problems, convert wildcard imports etc.. The IntelliJ formatter / import optimizer can fix these though.

@etanshaul etanshaul changed the title Add ktlint Add ktlint Kotlin linter via Spotless plugin Sep 20, 2018
@etanshaul
Copy link
Contributor Author

see the discussion here: Kotlin/kotlin-style-guide#15 (comment) w/regards to the formatting changes applied to SkaffoldUiResources. I agree with yole's comment, but looks like they went with it:

https://kotlinlang.org/docs/reference/coding-conventions.html#function-formatting

@etanshaul etanshaul requested a review from ivanporty September 20, 2018 19:08
@etanshaul
Copy link
Contributor Author

Here's the same rule in the Android style guide (which is the one we are following currently):
https://android.github.io/kotlin-guides/style.html#functions

Copy link
Contributor

@ivanporty ivanporty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting with parameter list, but this shouldn't happen very frequently anyway.

@etanshaul etanshaul merged commit c73619b into master Sep 21, 2018
@etanshaul etanshaul deleted the add-ktlint branch September 21, 2018 14:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Kotlin static analysis / code formatting tools
2 participants