-
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
Rewrite function signature rule #1341
Comments
paul-dingemans
pushed a commit
to paul-dingemans/ktlint
that referenced
this issue
Jan 22, 2022
This was referenced Jan 22, 2022
paul-dingemans
pushed a commit
to paul-dingemans/ktlint
that referenced
this issue
Feb 5, 2022
This rule lints and format the spacing between modifier in and after the last modifier in a modifier list. This rule is required to create a rule which can rewrite the function signature automatically as is described in pinterest#1341
2 tasks
paul-dingemans
pushed a commit
to paul-dingemans/ktlint
that referenced
this issue
Feb 5, 2022
Lints and formats the spacing after the fun keyword. This rule is required to create a rule which can rewrite the function signature automatically as is described in pinterest#1341
2 tasks
paul-dingemans
pushed a commit
to paul-dingemans/ktlint
that referenced
this issue
Feb 9, 2022
Autocorrect is not implemented. This is an error which only happens rarely. Its value is that it makes implementation of some rules way easier when comment do not have to be taken into account. Initial implementation just contains one single discouraged location. More will follow when implementing the rule to rewrite the function signature automatically as is described in pinterest#1341.
2 tasks
paul-dingemans
pushed a commit
to paul-dingemans/ktlint
that referenced
this issue
Feb 9, 2022
…eter list in a function signature This rule is required to create a rule which can rewrite the function signature automatically as is described in pinterest#1341
2 tasks
paul-dingemans
added a commit
that referenced
this issue
Mar 8, 2022
This rule is required to create a rule which can rewrite the function signature automatically as is described in #1341
paul-dingemans
added a commit
that referenced
this issue
Mar 9, 2022
This rule lints and format the spacing between modifier in and after the last modifier in a modifier list. This rule is required to create a rule which can rewrite the function signature automatically as is described in #1341
paul-dingemans
added a commit
that referenced
this issue
Mar 9, 2022
Lints and formats the spacing after the fun keyword. This rule is required to create a rule which can rewrite the function signature automatically as is described in #1341
paul-dingemans
added a commit
that referenced
this issue
Mar 9, 2022
Autocorrect is not implemented. This is an error which only happens rarely. Its value is that it makes implementation of some rules way easier when comment do not have to be taken into account. Initial implementation just contains one single discouraged location. More will follow when implementing the rule to rewrite the function signature automatically as is described in #1341.
paul-dingemans
added a commit
that referenced
this issue
Mar 13, 2022
…eter list in a function signature (#1366) Rule op-spacing should not handle characters like '<', '>' and '*' when not used as operator. This logic is moved to the TypeParameterListSpacingRule and new rule TypeArgumentListSpacingRule. This rule is required to create a rule which can rewrite the function signature automatically as is described in #1341
paul-dingemans
added a commit
to paul-dingemans/ktlint
that referenced
this issue
Mar 13, 2022
…n function name and the opening parenthesis Includes cleanup of AnnotationSpacingRuleTest as it broke due to existence of test which was not related to annotation spacing. Also removed the unneeded blank final line in code examples which are linted and formatted. This rule is required for implementing the function signature rewrite rule pinterest#1341
5 tasks
paul-dingemans
added a commit
to paul-dingemans/ktlint
that referenced
this issue
Mar 15, 2022
This rule is required for implementing the rewrite function signature rule pinterest#1341
This was referenced Mar 15, 2022
paul-dingemans
added a commit
to paul-dingemans/ktlint
that referenced
this issue
Mar 18, 2022
…rn type of a function This rule is required for implementing pinterest#1341.
Merged
5 tasks
paul-dingemans
added a commit
to paul-dingemans/ktlint
that referenced
this issue
Mar 19, 2022
…t of the body expression or body block This rule is required for implementing pinterest#1341.
5 tasks
paul-dingemans
added a commit
to paul-dingemans/ktlint
that referenced
this issue
Mar 20, 2022
…le type Required for implementing the signature rewrite rule (pinterest#1341)
5 tasks
paul-dingemans
added a commit
that referenced
this issue
Apr 26, 2022
Enforce consistent spacing (e.g. no whitespace element at all) between function name and the opening parenthesis This rule is required for implementing the function signature rewrite rule #1341
paul-dingemans
added a commit
that referenced
this issue
Apr 26, 2022
* Add new experimental rule ParameterListSpacingRule This rule is required for implementing the rewrite function signature rule #1341
paul-dingemans
added a commit
that referenced
this issue
Apr 26, 2022
* Add new experimental rule to check consistent spacing before the start of the body expression or body block This rule is required for implementing #1341.
paul-dingemans
added a commit
that referenced
this issue
Apr 26, 2022
* Add new experimental rule which prohibits whitespaces inside a nullable type Required for implementing the signature rewrite rule (#1341)
5 tasks
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
The Kotlin and Android code guidelines are more or less specific about how to write a function signature
From Android Coding style guide (https://developer.android.com/kotlin/style-guide#functions):
Although the Kotlin style guide is less specific about this topic (https://kotlinlang.org/docs/coding-conventions.html#functions) it boils down to the exact same format for multiline signatures.
The idea is to create a new rule that determines whether the function signature fits on a single line (with respect to the max_line_length) and if so, it rewrites the function signature to a single line. If the function signature does not fit on a single line, it will be formatted as shown in example before.
The concept of this rule is already working on my local machine. Known limitations so far:
One thing that I am doubting about is whether this rule should be made configurable a bit. Not in all cases I would like to have my function be rewritten automatically. For example, I do see no real harm in having a function with two parameters to be written on a single line if it first. Starting from 3 parameters, I would dislike it. So I would like to add a configuration setting for this rule which defines that a function signature will be forced to a multiline signature if the function has too many parameters for a single line function signature. By default this configuration setting will be empty and allow an unrestricted number of parameters.
Before this rule can be launched, I need some other rules which are fixing a few unhandled spacing issues in the function signature. I will raise a separate PR for each indivual rule.
The text was updated successfully, but these errors were encountered: