-
Notifications
You must be signed in to change notification settings - Fork 506
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
Class and function header format rules, autocorrection for IndentionRule #137
Merged
shyiko
merged 18 commits into
pinterest:master
from
MyDogTom:mydogtom/class-function-header-format
Jan 13, 2018
Merged
Class and function header format rules, autocorrection for IndentionRule #137
shyiko
merged 18 commits into
pinterest:master
from
MyDogTom:mydogtom/class-function-header-format
Jan 13, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enforce that parameters should be aligned. This is how default IntelliJ formatter works. This approach is listed on: https://ktlint.github.io/#rule-indentation https://kotlinlang.org/docs/reference/coding-conventions.html#class-header-formatting https://android.github.io/kotlin-guides/style.html#functions
Because rule is more strict now
Auto correction is disabled for parameters, because expected indent is not defined (parameter can be indented by multiple of "regular indent")
# Conflicts: # ktlint/src/main/kotlin/com/github/shyiko/ktlint/Main.kt
Parameters should be placed either on one line, either each parameter on new line Extracted indention size definition in separate class. This allows to avoid duplication between rules
# Conflicts: # ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/IndentationRule.kt
…t' into mydogtom/indention-complete # Conflicts: # ktlint-ruleset-standard/src/main/kotlin/com/github/shyiko/ktlint/ruleset/standard/IndentationRule.kt # ktlint-ruleset-standard/src/test/kotlin/com/github/shyiko/ktlint/ruleset/standard/IndentationRuleTest.kt
Applies only when header take more than one line
Because it will be reused in other rules
Because it's responsible for complete header formatting, not only parameters
This was referenced Jan 13, 2018
Thank you, @MyDogTom! Merging right in! |
Closed
This was referenced Jun 20, 2018
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains
ClassAndFunctionHeaderFormatRule
that implements Enforce wrapped parameter styling. #130IndentionRule
(fixes for ktlint not able to add spaces to indentation #116)Changes from #126 and #118 are included into current PR.
New rule notes
Applies to class definition (eg. primary constructor), secondary constructor and function.
Wrapping is needed in two cases:
Example
becomes this
See tests for more examples