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

Include rule ij_kotlin_wrap_first_method_in_call_chain = false #2603

Closed
Kolyall opened this issue Mar 11, 2024 · 5 comments
Closed

Include rule ij_kotlin_wrap_first_method_in_call_chain = false #2603

Kolyall opened this issue Mar 11, 2024 · 5 comments

Comments

@Kolyall
Copy link

Kolyall commented Mar 11, 2024

Versioin: 1.2.1

Rules:

[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_align_multiline_parameters = true
ij_kotlin_align_multiline_parameters_in_calls = true
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_block_comment_add_space = true
ij_kotlin_call_parameters_new_line_after_left_paren = true
ij_kotlin_call_parameters_right_paren_on_new_line = true
ij_kotlin_call_parameters_wrap = split_into_lines
ij_kotlin_catch_on_new_line = false
ij_kotlin_class_annotation_wrap = split_into_lines
ij_kotlin_else_on_new_line = false
ij_kotlin_enum_constants_wrap = split_into_lines
ij_kotlin_extends_list_wrap = split_into_lines
ij_kotlin_field_annotation_wrap = split_into_lines
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = false
ij_kotlin_import_nested_classes = false
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
ij_kotlin_keep_blank_lines_in_code = 1
ij_kotlin_keep_blank_lines_in_declarations = 1
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_comment_add_space = true
ij_kotlin_line_comment_add_space_on_reformat = true
ij_kotlin_method_annotation_wrap = split_into_lines
ij_kotlin_method_parameters_new_line_after_left_paren = true
ij_kotlin_method_parameters_right_paren_on_new_line = true
ij_kotlin_method_parameters_wrap = split_into_lines
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = kotlinx.android.synthetic.**
ij_kotlin_parameter_annotation_wrap = split_into_lines
ij_kotlin_space_after_comma = true
ij_kotlin_space_after_extend_colon = true
ij_kotlin_space_after_type_colon = true
ij_kotlin_space_before_catch_parentheses = true
ij_kotlin_space_before_comma = false
ij_kotlin_space_before_extend_colon = true
ij_kotlin_space_before_for_parentheses = true
ij_kotlin_space_before_if_parentheses = true
ij_kotlin_space_before_lambda_arrow = true
ij_kotlin_space_before_type_colon = false
ij_kotlin_space_before_when_parentheses = true
ij_kotlin_space_before_while_parentheses = true
ij_kotlin_spaces_around_additive_operators = true
ij_kotlin_spaces_around_assignment_operators = true
ij_kotlin_spaces_around_equality_operators = true
ij_kotlin_spaces_around_function_type_arrow = true
ij_kotlin_spaces_around_logical_operators = true
ij_kotlin_spaces_around_multiplicative_operators = true
ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_use_custom_formatting_for_modifiers = true

# KtLint configuration
ktlint_code_style = ktlint_official
ktlint_experimental = enabled
ktlint_standard_package-name = disabled
ktlint_standard_function-expression-body = disabled
ktlint_standard_max-line-length = disabled
ktlint_standard_backing-property-naming = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_no-consecutive-comments = disabled
ktlint_standard_kdoc = disabled
ktlint_standard_no-wildcard-imports = disabled
ktlint_standard_filename = disabled
ktlint_standard_comment-wrapping = disabled
ktlint_standard_if-else-wrapping = disabled
ktlint_standard_enum-entry-name-case = disabled
ktlint_standard_no-empty-file = disabled
ktlint_standard_value-parameter-comment = disabled
ktlint_standard_class-naming = disabled
ktlint_standard_value-argument-comment = disabled
ktlint_standard_function-naming = disabled

ktlint_standard_binary-expression-wrapping = disabled
ktlint_standard_no-empty-first-line-in-class-body = disabled
ktlint_standard_no-single-line-block-comment = disabled
ktlint_standard_multiline-if-else = enabled
ktlint_standard_no-blank-line-before-rbrace = enabled
ktlint_standard_no-blank-lines-in-chained-method-calls = enabled
ktlint_standard_no-consecutive-blank-lines = enabled
ktlint_standard_no-empty-class-body = enabled
ktlint_standard_no-empty-first-line-in-method-block = disabled
ktlint_standard_no-line-break-after-else = enabled
ktlint_standard_no-line-break-before-assignment = enabled
ktlint_standard_no-multi-spaces = enabled
ktlint_standard_no-semi = enabled
ktlint_standard_no-unit-return = enabled
ktlint_standard_no-unused-imports = enabled
ktlint_standard_spacing-around-angle-brackets = enabled
ktlint_standard_annotation-spacing = enabled
ktlint_standard_spacing-between-declarations-with-annotations = enabled
ktlint_standard_spacing-between-declarations-with-comments = enabled
ktlint_standard_colon-spacing = enabled
ktlint_standard_comma-spacing = enabled
ktlint_standard_comment-spacing = enabled
ktlint_standard_curly-spacing = enabled
ktlint_standard_dot-spacing = enabled
ktlint_standard_double-colon-spacing = enabled
ktlint_standard_function-return-type-spacing = enabled
ktlint_standard_function-start-of-body-spacing = enabled
ktlint_standard_function-type-reference-spacing = enabled
ktlint_standard_fun-keyword-spacing = enabled
ktlint_standard_kdoc-wrapping = enabled
ktlint_standard_keyword-spacing = enabled
ktlint_standard_modifier-list-spacing = enabled
ktlint_standard_nullable-type-spacing = enabled
ktlint_standard_op-spacing = enabled
ktlint_standard_parameter-list-spacing = enabled
ktlint_standard_paren-spacing = enabled
ktlint_standard_range-spacing = enabled
ktlint_standard_spacing-between-function-name-and-opening-parenthesis = enabled
ktlint_standard_try-catch-finally-spacing = enabled
ktlint_standard_type-argument-list-spacing = enabled
ktlint_standard_type-parameter-list-spacing = enabled
ktlint_standard_unary-op-spacing = enabled
ktlint_standard_string-template = disabled
ktlint_standard_string-template-indent = disabled
# ktlint_standard_trailing-comma-on-call-site = enabled
ktlint_standard_trailing-comma-on-call-site = disabled
# ktlint_standard_trailing-comma-on-declaration-site = enabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_type-argument-comment = enabled
ktlint_standard_type-parameter-comment = enabled
ktlint_standard_unnecessary-parentheses-before-trailing-lambda = enabled
ktlint_standard_value-argument-comment = enabled
ktlint_standard_value-parameter-comment = enabled
ktlint_standard_argument-list-wrapping = enabled
ktlint_argument_list_wrapping_ignore_when_parameter_count_greater_or_equal_than = 1
# ktlint_standard_chain-wrapping = enabled
ktlint_standard_chain-wrapping = disabled
ktlint_standard_comment-wrapping = enabled
ktlint_standard_context-receiver-wrapping = enabled
ktlint_standard_enum-wrapping = enabled
ktlint_standard_if-else-wrapping = enabled
ktlint_standard_multiline-expression-wrapping = disabled
ktlint_standard_parameter-list-wrapping = disabled
ktlint_standard_parameter-wrapping = disabled
ktlint_standard_property-wrapping = disabled
ktlint_standard_statement-wrapping = enabled
ktlint_standard_wrapping = disabled
ij_kotlin_wrap_first_method_in_call_chain = false

Result:

viewModel
            .getUserStatus()
            .onEach {}
            .launchIn(viewLifecycleOwner.lifecycleScope)

Expected result:

viewModel.getUserStatus()
            .onEach {}
            .launchIn(viewLifecycleOwner.lifecycleScope)
@paul-dingemans
Copy link
Collaborator

Sorry but this will not be implemented as it conflicts with chain-method-continuation which aligns/wraps all . and ?. before call expressions. Also, there will be no option added to make this configurable (https://pinterest.github.io/ktlint/latest/faq/#can-a-new-toggle-be-added-to-optionally-enabledisable-format-code-in-a-particular-way).

@paul-dingemans paul-dingemans closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@Kolyall
Copy link
Author

Kolyall commented Mar 13, 2024

@paul-dingemans it conflicts with chain-method-continuation only if chain-method-continuation = 1.
And in this case you may notify user about this conflict

@paul-dingemans
Copy link
Collaborator

only if chain-method-continuation = 1.

What do you mean with this?

@Kolyall
Copy link
Author

Kolyall commented Mar 14, 2024

@paul-dingemans
Cases:

  1. If config is:
ktlint_standard_chain-method-continuation = 1
ij_kotlin_wrap_first_method_in_call_chain = false

Expected result will be:
conflict

  1. If config is:
ktlint_standard_chain-method-continuation = 2
ij_kotlin_wrap_first_method_in_call_chain = false

Expected result will be:

viewModel.getUserStatus()
            .onEach {}
            .launchIn(viewLifecycleOwner.lifecycleScope)
  1. If config is:
ktlint_standard_chain-method-continuation = 3
ij_kotlin_wrap_first_method_in_call_chain = false

Expected result will be:

viewModel.getUserStatus().onEach {}
            .launchIn(viewLifecycleOwner.lifecycleScope)

@paul-dingemans
Copy link
Collaborator

Why do you think that property ktlint_standard_chain-method-continuation can have a numeric value? This property can only be set with value enabled or disabled. The only numeric property for this rule is ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than. See https://pinterest.github.io/ktlint/latest/rules/experimental/#chain-method-continuation.

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

No branches or pull requests

2 participants