pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.06k stars 504 forks source link

Ktlint Issue: Variable Declaration Format Inconsistency Despite Disabled Max-Line-Length Constraint #2623

Closed lonewolf2208 closed 2 months ago

lonewolf2208 commented 3 months ago

Expected Behavior

The ktlint Check should pass for the variable declaration like given below (given that I have disabled ktlint_standard_max-line-length = disabled in the .editorconfig file ) - private val saveFeedbackInteractionLoanApplicationIdUseCase: SaveFeedbackInteractionLoanApplicationIdUseCase, private val getFeedbackInteractionLoanApplicationIdUseCase: GetFeedbackInteractionLoanApplicationIdUseCase

Observed Behavior

Failing getting the error. - Missing newline before "SaveFeedbackInteractionLoanApplicationIdUseCase" Missing newline before "GetFeedbackInteractionLoanApplicationIdUseCase"

Other cases where it is failing. - private val getSecondaryButtonFromLendingAccountDetailsUseCase: GetSecondaryButtonFromLendingAccountDetailsUseCase private val isBiometricEnrollmentAttemptWithinLimitUseCase: IsBiometricEnrollmentAttemptWithinLimitUseCase

Your Environment

Work Around

Changing variable names to a shorter one

paul-dingemans commented 3 months ago

.editorconfig setting ktlint_standard_max-line-length = disabled only results in disabling the max-line-length rule.

In the output of Ktlint CLI you can see that the error is caused by property-wrapping rule:

Missing newline before "SaveFeedbackInteractionLoanApplicationIdUseCase" (standard:property-wrapping)
Missing newline before "GetFeedbackInteractionLoanApplicationIdUseCase" (standard:property-wrapping)

By using ktlint_code_style set to android the max_line_length property is set by default to 100. Disabling ktlint_standard_max-line-length does not change that value. This value is used by multiple rules. To fully disable all length line checks, you can set max_line_length to value unset.

lonewolf2208 commented 3 months ago

Thanks @paul-dingemans for the input . Can we disbale the standard:property-wrapping rule ? I tried to disable it using ktlint_standard_property-wrapping = disabled.

paul-dingemans commented 2 months ago

Thanks @paul-dingemans for the input . Can we disbale the standard:property-wrapping rule ? I tried to disable it using ktlint_standard_property-wrapping = disabled.

Sure, but the better solution would be to configure it in .editorconfig:

root = true

[*.{kt,kts}]
max_line_length = unset

Reason for this is that more rules look at the max_line_length property.

paul-dingemans commented 2 months ago

OP has not responded. Issue is considered resolved with solution given above.