Repository: detekt/detekt (kotlin)

Issue:
Generated config yaml comment states false claim
#7959 removed the `android` configuration property in favor of code_style but the generated default configuration still references the old property.

For example:
```yaml
  ArgumentListWrapping:
    active: true
    autoCorrect: true
    indentSize: 4
    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
    ignoreRuleParameterThreshold: 8
```

Pull request description:
Fixes: https://github.com/detekt/detekt/issues/8703

Patch:
diff --git a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinter.kt b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinter.kt
index 145a8f6f929..a0e033e20aa 100644
--- a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinter.kt
+++ b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinter.kt
@@ -57,7 +57,7 @@ internal fun YamlNode.printConfiguration(configuration: Configuration) {
 
     if (hasDeviatingAndroidDefault) {
         val description =
-            "If the 'android' ruleset property is set to true, " +
+            "If the 'code_style' ruleset property is set to 'android', " +
                 "the default is '${configuration.defaultAndroidValue.getPlainValue()}', " +
                 "otherwise '${configuration.defaultValue.getPlainValue()}'."
         comment("${configuration.name}: $description")
diff --git a/detekt-rules-ktlint-wrapper/src/main/resources/config/config.yml b/detekt-rules-ktlint-wrapper/src/main/resources/config/config.yml
index 916d43abdfc..f5e4127538e 100644
--- a/detekt-rules-ktlint-wrapper/src/main/resources/config/config.yml
+++ b/detekt-rules-ktlint-wrapper/src/main/resources/config/config.yml
@@ -13,14 +13,14 @@ ktlint:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     ignoreRuleParameterThreshold: 8
   BackingPropertyNaming:
     active: true
   BinaryExpressionWrapping:
     active: true
     autoCorrect: true
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     indentSize: 4
   BlankLineBeforeDeclaration:
     active: true
@@ -36,7 +36,7 @@ ktlint:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     forceMultilineWhenChainOperatorCountGreaterOrEqualThan: 4
   ChainWrapping:
     active: true
@@ -48,7 +48,7 @@ ktlint:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   CommentSpacing:
     active: true
     autoCorrect: true
@@ -63,12 +63,12 @@ ktlint:
   ContextReceiverListWrapping:
     active: true
     autoCorrect: true
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     indentSize: 4
   ContextReceiverMapping:
     active: true
     autoCorrect: true
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     indentSize: 4
   EnumEntryNameCase:
     active: true
@@ -96,24 +96,24 @@ ktlint:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   FunctionLiteral:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   FunctionName:
     active: false
   FunctionReturnTypeSpacing:
     active: true
     autoCorrect: true
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   FunctionSignature:
     active: true
     autoCorrect: true
     forceMultilineWhenParameterCountGreaterOrEqualThan: 2147483647
     functionBodyExpressionWrapping: 'default'
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     indentSize: 4
   FunctionStartOfBodySpacing:
     active: true
@@ -135,7 +135,7 @@ ktlint:
   ImportOrdering:
     active: true
     autoCorrect: true
-    # layout: If the 'android' ruleset property is set to true, the default is '*', otherwise '*,java.**,javax.**,kotlin.**,^'.
+    # layout: If the 'code_style' ruleset property is set to 'android', the default is '*', otherwise '*,java.**,javax.**,kotlin.**,^'.
   Indentation:
     active: true
     autoCorrect: true
@@ -150,7 +150,7 @@ ktlint:
   MaximumLineLength:
     active: true
     aliases: ['MaxLineLength']
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     ignoreBackTickedIdentifier: false
   MixedConditionOperators:
     active: false
@@ -236,17 +236,17 @@ ktlint:
   ParameterListSpacing:
     active: true
     autoCorrect: true
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   ParameterListWrapping:
     active: true
     autoCorrect: true
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
     indentSize: 4
   ParameterWrapping:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   PropertyName:
     active: true
     constantNamingStyle: 'screaming_snake_case'
@@ -254,7 +254,7 @@ ktlint:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
   SpacingAroundAngleBrackets:
     active: true
     autoCorrect: true
@@ -315,11 +315,11 @@ ktlint:
   TrailingCommaOnCallSite:
     active: true
     autoCorrect: true
-    # useTrailingCommaOnCallSite: If the 'android' ruleset property is set to true, the default is 'false', otherwise 'true'.
+    # useTrailingCommaOnCallSite: If the 'code_style' ruleset property is set to 'android', the default is 'false', otherwise 'true'.
   TrailingCommaOnDeclarationSite:
     active: true
     autoCorrect: true
-    # useTrailingCommaOnDeclarationSite: If the 'android' ruleset property is set to true, the default is 'false', otherwise 'true'.
+    # useTrailingCommaOnDeclarationSite: If the 'code_style' ruleset property is set to 'android', the default is 'false', otherwise 'true'.
   TryCatchFinallySpacing:
     active: true
     autoCorrect: true
@@ -351,4 +351,4 @@ ktlint:
     active: true
     autoCorrect: true
     indentSize: 4
-    # maxLineLength: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+    # maxLineLength: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.


Test patch:
diff --git a/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/ConfigPrinterSpec.kt b/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/ConfigPrinterSpec.kt
index 22fd7a30b3a..2e4ca0ce0d7 100644
--- a/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/ConfigPrinterSpec.kt
+++ b/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/ConfigPrinterSpec.kt
@@ -29,7 +29,7 @@ class ConfigPrinterSpec {
                 conf3:
                   - 'a'
                   - 'b'
-                # conf5: If the 'android' ruleset property is set to true, the default is '100', otherwise '120'.
+                # conf5: If the 'code_style' ruleset property is set to 'android', the default is '100', otherwise '120'.
               EqualsNull:
                 active: false
               NoUnitKeyword:
diff --git a/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt b/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt
index 2f656fe7a61..5d763060e1e 100644
--- a/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt
+++ b/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/defaultconfig/RuleSetConfigPrinterTest.kt
@@ -230,6 +230,16 @@ internal class RuleSetConfigPrinterTest {
                 """.trimIndent()
                 assertThat(actual).isEqualTo(expected)
             }
+
+            @Test
+            fun `android default values`() {
+                val given = configurationTemplate.copy(defaultAndroidValue = DefaultValue.of(2))
+                val actual = yaml { printConfiguration(given) }
+                val expected = """
+                    # name: If the 'code_style' ruleset property is set to 'android', the default is '2', otherwise '1'.
+                """.trimIndent()
+                assertThat(actual).isEqualTo(expected)
+            }
         }
     }
 }