From 08c3afc8158c9121f4c6ebc6d872712bc01aacf7 Mon Sep 17 00:00:00 2001 From: Antonio Aversa Date: Wed, 22 Jan 2025 14:19:31 +0100 Subject: [PATCH 1/2] SONARKT-429 Fix UTs on Windows with autocrlf true --- .../sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt index 863bc53bd..12088a6f3 100644 --- a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt +++ b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt @@ -16,6 +16,7 @@ */ package org.sonarsource.kotlin.plugin +import org.assertj.core.api.Assert import org.assertj.core.api.Assertions import org.junit.jupiter.api.Test import org.sonar.api.SonarEdition @@ -38,7 +39,11 @@ internal class KotlinRulesDefinitionTest { .isEqualTo("Identical expressions should not be used on both sides of a binary operator") Assertions.assertThat(rule.type()).isEqualTo(RuleType.BUG) Assertions.assertThat(rule.scope()).isEqualTo(RuleScope.ALL) - Assertions.assertThat(rule.htmlDescription()).startsWith("

Why is this an issue?

\n

Using the same value on both sides") + val htmlDescription = rule.htmlDescription()?.lines(); + Assertions.assertThat(htmlDescription?.getOrNull(0)) + .startsWith("

Why is this an issue?

") + Assertions.assertThat(htmlDescription?.getOrNull(1)) + .startsWith("

Using the same value on both sides") val ruleWithConfig = repository.rule("S100") val param = ruleWithConfig!!.param("format") Assertions.assertThat(param!!.defaultValue()).isEqualTo("^[a-zA-Z][a-zA-Z0-9]*$") From 1d160dec2f290891e6b0c43f47120834510b8e5c Mon Sep 17 00:00:00 2001 From: Antonio Aversa Date: Mon, 27 Jan 2025 13:34:22 +0100 Subject: [PATCH 2/2] Code review: use !! on htmlDescription lines --- .../sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt index 12088a6f3..07371693c 100644 --- a/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt +++ b/sonar-kotlin-plugin/src/test/java/org/sonarsource/kotlin/plugin/KotlinRulesDefinitionTest.kt @@ -39,10 +39,10 @@ internal class KotlinRulesDefinitionTest { .isEqualTo("Identical expressions should not be used on both sides of a binary operator") Assertions.assertThat(rule.type()).isEqualTo(RuleType.BUG) Assertions.assertThat(rule.scope()).isEqualTo(RuleScope.ALL) - val htmlDescription = rule.htmlDescription()?.lines(); - Assertions.assertThat(htmlDescription?.getOrNull(0)) + val htmlDescription = rule.htmlDescription()!!.lines() + Assertions.assertThat(htmlDescription.getOrNull(0)) .startsWith("

Why is this an issue?

") - Assertions.assertThat(htmlDescription?.getOrNull(1)) + Assertions.assertThat(htmlDescription.getOrNull(1)) .startsWith("

Using the same value on both sides") val ruleWithConfig = repository.rule("S100") val param = ruleWithConfig!!.param("format")