Repository: detekt/detekt (kotlin)

Issue:
Ruleset configuration options missing in documentation
## Expected Behavior
All ruleset configuration options should be mentioned in the documentation.

## Observed Behavior
The configuration options `code_style` and `autoCorrect` from the formatting ruleset are not mentioned in the [ruleset documentation](https://detekt.dev/docs/next/rules/formatting).

Pull request:
fixes #8526

The first commit is the actual change, the second one renames the printer to reflect what it is actually doing.

Patch:
diff --git a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleConfigurationPrinter.kt b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/ConfigurationsPrinter.kt
similarity index 94%
rename from detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleConfigurationPrinter.kt
rename to detekt-generator/src/main/kotlin/dev/detekt/generator/printer/ConfigurationsPrinter.kt
index 6b5f7b27e431..365183787534 100644
--- a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleConfigurationPrinter.kt
+++ b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/ConfigurationsPrinter.kt
@@ -10,7 +10,7 @@ import dev.detekt.utils.item
 import dev.detekt.utils.list
 import dev.detekt.utils.markdown
 
-internal object RuleConfigurationPrinter : DocumentationPrinter<List<Configuration>> {
+internal object ConfigurationsPrinter : DocumentationPrinter<List<Configuration>> {
 
     override fun print(item: List<Configuration>): String {
         if (item.isEmpty()) return ""
diff --git a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RulePrinter.kt b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RulePrinter.kt
index 44ecb3fc933b..7540cf41ef09 100644
--- a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RulePrinter.kt
+++ b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RulePrinter.kt
@@ -45,7 +45,7 @@ internal object RulePrinter : DocumentationPrinter<Rule> {
                 }
             }
 
-            markdown { RuleConfigurationPrinter.print(item.configurations) }
+            markdown { ConfigurationsPrinter.print(item.configurations) }
 
             printRuleCodeExamples(item)
         }
diff --git a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleSetPagePrinter.kt b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleSetPagePrinter.kt
index 892daf3cb9fa..9f01ac24c036 100644
--- a/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleSetPagePrinter.kt
+++ b/detekt-generator/src/main/kotlin/dev/detekt/generator/printer/RuleSetPagePrinter.kt
@@ -13,6 +13,8 @@ object RuleSetPagePrinter : DocumentationPrinter<RuleSetPage> {
             } else {
                 paragraph { "TODO: Specify description" }
             }
+            markdown { ConfigurationsPrinter.print(item.ruleSet.configuration) }
+
             item.rules.forEach {
                 markdown { RulePrinter.print(it) }
             }


Test patch:
diff --git a/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/RuleConfigurationPrinterTest.kt b/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/ConfigurationsPrinterSpec.kt
similarity index 82%
rename from detekt-generator/src/test/kotlin/dev/detekt/generator/printer/RuleConfigurationPrinterTest.kt
rename to detekt-generator/src/test/kotlin/dev/detekt/generator/printer/ConfigurationsPrinterSpec.kt
index 9a5b12981a8e..d088116930df 100644
--- a/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/RuleConfigurationPrinterTest.kt
+++ b/detekt-generator/src/test/kotlin/dev/detekt/generator/printer/ConfigurationsPrinterSpec.kt
@@ -7,7 +7,7 @@ import org.assertj.core.api.Assertions.assertThat
 import org.junit.jupiter.api.Nested
 import org.junit.jupiter.api.Test
 
-internal class RuleConfigurationPrinterTest {
+internal class ConfigurationsPrinterSpec {
     private val configTemplate = Configuration(
         name = "configName",
         description = "config description",
@@ -21,42 +21,42 @@ internal class RuleConfigurationPrinterTest {
         @Test
         fun `boolean default`() {
             val config = configTemplate.copy(defaultValue = DefaultValue.of(true))
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``true``)""")
         }
 
         @Test
         fun `int default`() {
             val config = configTemplate.copy(defaultValue = DefaultValue.of(99))
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``99``)""")
         }
 
         @Test
         fun `int default with groupings`() {
             val config = configTemplate.copy(defaultValue = DefaultValue.of(99_999))
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``99999``)""")
         }
 
         @Test
         fun `string default`() {
             val config = configTemplate.copy(defaultValue = DefaultValue.of("abc"))
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``'abc'``)""")
         }
 
         @Test
         fun `string list default`() {
             val config = configTemplate.copy(defaultValue = DefaultValue.of(listOf("a", "b", "c")))
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``['a', 'b', 'c']``)""")
         }
 
         @Test
         fun `empty string list default`() {
             val config = configTemplate.copy(defaultValue = DefaultValue.of(emptyList()))
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``[]``)""")
         }
 
@@ -71,7 +71,7 @@ internal class RuleConfigurationPrinterTest {
                     )
                 )
             )
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``['a', 'b', 'c']``)""")
         }
 
@@ -81,7 +81,7 @@ internal class RuleConfigurationPrinterTest {
                 defaultValue = DefaultValue.of(99),
                 defaultAndroidValue = DefaultValue.of(100)
             )
-            val actual = RuleConfigurationPrinter.print(listOf(config))
+            val actual = ConfigurationsPrinter.print(listOf(config))
             assertThat(actual).contains("""* ``configName`` (default: ``99``) (android default: ``100``)""")
         }
     }
@@ -89,7 +89,7 @@ internal class RuleConfigurationPrinterTest {
     @Nested
     inner class DeprecatedProperties {
         private val config = configTemplate.copy(deprecated = "Use something else instead")
-        private val actual = RuleConfigurationPrinter.print(listOf(config))
+        private val actual = ConfigurationsPrinter.print(listOf(config))
 
         @Test
         fun `contain deprecation information`() {
diff --git a/detekt-generator/src/test/resources/RuleSet.md b/detekt-generator/src/test/resources/RuleSet.md
index d6be0f064056..355ed612a828 100644
--- a/detekt-generator/src/test/resources/RuleSet.md
+++ b/detekt-generator/src/test/resources/RuleSet.md
@@ -1,5 +1,31 @@
 style rule set
 
+#### Configuration options:
+
+* ``rulesetconfig1`` (default: ``true``)
+
+  description rulesetconfig1
+
+* ``rulesetconfig2`` (default: ``['foo', 'bar']``)
+
+  description rulesetconfig2
+
+* ~~``deprecatedSimpleConfig``~~ (default: ``true``)
+
+  **Deprecated**: is deprecated
+
+  description deprecatedSimpleConfig
+
+* ~~``deprecatedListConfig``~~ (default: ``['foo', 'bar']``)
+
+  **Deprecated**: is deprecated
+
+  description deprecatedListConfig
+
+* ``rulesetconfig3`` (default: ``['first', 'se*cond']``)
+
+  description rulesetconfig2
+
 ### MagicNumber
 
 a wildcard import