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

Add new experimental rule "function-signature" #1459

Merged

Conversation

paul-dingemans
Copy link
Collaborator

Description

This rule rewrites the function signature to a single line when possible (e.g. when not exceeding the "max_line_length" property) or a multiline signature otherwise. In case of function with a body expression, the body expression is placed on the same line as the function signature when not exceeding the "max_line_length" property. Optionally the function signature can be forced to be written as a multiline signature in case the function has more than a specified number of parameters (".editorconfig" property "ktlint_function_signature_wrapping_rule_always_with_minimum_parameters")

Fixed the FunctionStartOfBodySpacingRule to add the missing space before start of the block body before the BLOCK element type instead of as first element inside the BLOCK element.

Closes #1341

Checklist

  • PR description added
  • tests are added
  • CHANGELOG.md is updated

In case of adding a new rule:

  • README.md is updated
  • Rule has been applied on Ktlint itself and violations are fixed

= added 3 commits May 1, 2022 20:34
This rule rewrites the function signature to a single line when possible (e.g. when not exceeding the "max_line_length" property) or a multiline signature otherwise. In case of function with a body expression, the body expression is placed on the same line as the function signature when not exceeding the "max_line_length" property. Optionally the function signature can be forced to be written as a multiline signature in case the function has more than a specified number of parameters (".editorconfig" property "ktlint_function_signature_wrapping_rule_always_with_minimum_parameters")

Fixed the FunctionStartOfBodySpacingRule to add the missing space before start of the block body before the BLOCK element type instead of as first element inside the BLOCK element.
@paul-dingemans paul-dingemans merged commit e480944 into pinterest:master May 18, 2022
@paul-dingemans paul-dingemans deleted the 1341-function-signature-rewrite branch May 18, 2022 18:51
@paul-dingemans paul-dingemans added this to the 0.46.0 milestone May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite function signature rule
1 participant