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

function-signature does not respect max_line_length #2296

Closed
jakoss opened this issue Oct 9, 2023 · 3 comments · Fixed by #2301
Closed

function-signature does not respect max_line_length #2296

jakoss opened this issue Oct 9, 2023 · 3 comments · Fixed by #2301
Milestone

Comments

@jakoss
Copy link

jakoss commented Oct 9, 2023

Expected Behavior

override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 
    super.onViewCreated(view, savedInstanceState) 
} 

My max_line_length is 180, i tried to turn off ktlint_function_signature_wrapping_rule_always_with_minimum_parameters. As far as i understand this should leave my line intact, but ktlint seems to always force multiline parameters when i have more than 1 parameter. It works correctly for a single parameter.. My .editorconfig is further down.

Observed Behavior

override fun onViewCreated( 
	view: View, 
    savedInstanceState: Bundle?, 
) {  
   super.onViewCreated(view, savedInstanceState) 
} 

Steps to Reproduce

Running the ktlint 1.0.0 from CLI on given code should give the observed behavior.

Your Environment

  • Version of ktlint used: 1.0.0
  • Relevant parts of the .editorconfig settings
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): CLI
  • Version of Gradle used (if applicable): run from CLI
  • Operating System and version: MacOS Sonoma

My .editorconfig properties related to ktlint:

[*]
charset = utf-8
end_of_line = crlf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 180
tab_width = 4
trim_trailing_whitespace = true

[{*.kt,*.kts}]
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_no-empty-class-body = disabled
ktlint_standard_import-ordering = disabled
# Necessary for compatibility with Compose
ktlint_standard_function-naming = disabled
ktlint_standard_annotation = disabled

ktlint_function_signature_wrapping_rule_always_with_minimum_parameters = disabled

Log from ktlint CLI:

MessageFragment.kt:29:32: Newline expected after opening parenthesis (standard:function-signature)
MessageFragment.kt:29:44: Parameter should start on a newline (standard:function-signature)
MessageFragment.kt:29:71: Newline expected before closing parenthesis (standard:function-signature)
@paul-dingemans
Copy link
Collaborator

ktlint_function_signature_wrapping_rule_always_with_minimum_parameters is not a property that is recognized by ktlint. On what information did you assume that this would work?

See rule documentation and configuration properties for more information.

@jakoss
Copy link
Author

jakoss commented Oct 9, 2023

@paul-dingemans It is literally there, just in the link to rule documentation you posted:
image

Setting ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than works correctly, but the docs to function signature (https://pinterest.github.io/ktlint/1.0.0/rules/standard/#function-signature) is misleading

@paul-dingemans
Copy link
Collaborator

@paul-dingemans It is literally there, just in the link to rule documentation you posted:

Ow, that is pretty embarassing. Let me reopen this issue until docs are fixed.

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 a pull request may close this issue.

2 participants