Skip to content

Commit

Permalink
Improve test coverage (#3622)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Schwarz <post@markus-schwarz.net>
  • Loading branch information
marschwar and Markus Schwarz committed Mar 29, 2021
1 parent 0e680c4 commit 14f655e
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ inline fun MarkdownContent.list(listContent: MarkdownList.() -> Unit) {
}

inline fun MarkdownList.item(item: () -> String) = append("* ${item()}\n")
inline fun MarkdownList.description(description: () -> String) = append(" ${description()}\n")
inline fun MarkdownList.description(description: () -> String) = append(" ${description()}\n")
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,27 @@ import io.gitlab.arturbosch.detekt.generator.printer.rulesetpage.RuleSetPage

internal fun createRuleSetPage(): RuleSetPage {
val rules = createRules()
val ruleSetProvider = RuleSetProvider("style", "style rule set", Active("1.0.0"), rules.map { it.name })
val ruleSetProvider =
RuleSetProvider(
name = "style",
description = "style rule set",
defaultActivationStatus = Active("1.0.0"),
rules = rules.map { it.name },
configuration = listOf(
Configuration(
name = "rulesetconfig1",
description = "description rulesetconfig1",
defaultValue = "true",
deprecated = null
),
Configuration(
name = "rulesetconfig2",
description = "description rulesetconfig2",
defaultValue = "['foo', 'bar']",
deprecated = "is deprecated"
)
)
)
return RuleSetPage(ruleSetProvider, rules)
}

Expand All @@ -26,7 +46,8 @@ internal fun createRules(): List<Rule> {
parent = "",
configuration = listOf(
Configuration("conf1", "a config option", "foo", null),
Configuration("conf2", "deprecated config", "false", "use conf1 instead")
Configuration("conf2", "deprecated config", "false", "use conf1 instead"),
Configuration("conf3", "list config", "['a', 'b']", null),
)
)
val rule2 = Rule(
Expand Down
10 changes: 7 additions & 3 deletions detekt-generator/src/test/resources/RuleSet.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ a wildcard import

* ``conf1`` (default: ``foo``)

a config option
a config option

* ~~``conf2``~~ (default: ``false``)

**Deprecated**: use conf1 instead
**Deprecated**: use conf1 instead

deprecated config
deprecated config

* `conf3` (default: `['a', 'b']`)

list config

#### Noncompliant Code:

Expand Down
3 changes: 3 additions & 0 deletions detekt-generator/src/test/resources/RuleSetConfig.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
style:
active: true
rulesetconfig1: true
rulesetconfig2: ['foo', 'bar']
WildcardImport:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
conf1: foo
conf3: ['a', 'b']
EqualsNull:
active: false
NoUnitKeyword:
Expand Down

0 comments on commit 14f655e

Please sign in to comment.