Skip to content

Commit

Permalink
Do not log warning "Format was not able to resolve all violations"
Browse files Browse the repository at this point in the history
The warning "Format was not able to resolve all violations" should not be logged in case the code only contains lint violations which may not be autocorrected according to the AutoCorrectHandler.

Closes #2726
  • Loading branch information
paul-dingemans committed Jul 2, 2024
1 parent 15fb36d commit 32949f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public class ChainMethodContinuationRule :
private val chainOperatorTokenSet = TokenSet.create(DOT, SAFE_ACCESS)
private val groupClosingElementType = TokenSet.create(CLOSING_QUOTE, RBRACE, RBRACKET, RPAR)

private const val FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY_UNSET = 4
private const val FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY_UNSET = Int.MAX_VALUE
public val FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY: EditorConfigProperty<Int> =
EditorConfigProperty(
type =
Expand All @@ -500,7 +500,7 @@ public class ChainMethodContinuationRule :
PropertyType.PropertyValueParser.POSITIVE_INT_VALUE_PARSER,
setOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "unset"),
),
defaultValue = FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY_UNSET,
defaultValue = 4,
propertyMapper = { property, _ ->
if (property?.isUnset == true) {
FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY_UNSET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1117,4 +1117,16 @@ class ChainMethodContinuationRuleTest {
LintViolation(4, 59, "Expected newline before '.'"),
).isFormattedAs(formattedCode)
}

@Test
fun `Issue 2712 - Given some code having more chain operators than the default, but with ktlint_chain_method_rule_force_multiline_when_chain_operator_count_greater_or_equal_than unset`() {
val code =
"""
val foo = listOf(1, 2, 3).plus(4).plus(5).plus(6).plus(7).plus(8)
""".trimIndent()
require(code.count { it == '.' } > FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY.defaultValue)
chainMethodContinuationRuleAssertThat(code)
.withEditorConfigOverride(FORCE_MULTILINE_WHEN_CHAIN_OPERATOR_COUNT_GREATER_OR_EQUAL_THAN_PROPERTY to "unset")
.hasNoLintViolations()
}
}

0 comments on commit 32949f7

Please sign in to comment.