Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Add config generator for custom rules
- Loading branch information
1 parent
6d39566
commit 088ebb7
Showing
9 changed files
with
60 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...-generator/src/test/kotlin/io/gitlab/arturbosch/detekt/generator/printer/GeneratorSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.gitlab.arturbosch.detekt.generator.printer | ||
|
||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
|
||
class GeneratorSpec { | ||
@Test | ||
fun `config files generated successfully`() { | ||
assertThat(File("$folder1$configPath")).exists() | ||
assertThat(File("$folder2$configPath")).exists() | ||
} | ||
|
||
@Test | ||
fun `config files have proper content`() { | ||
assertThat(File("$folder1$configPath").readText()) | ||
.contains("complexity:") | ||
.doesNotContain("coroutines:") | ||
|
||
assertThat(File("$folder2$configPath").readText()) | ||
.contains("coroutines:") | ||
.doesNotContain("complexity:") | ||
} | ||
|
||
companion object { | ||
private const val folder1 = "../detekt-rules-complexity" | ||
private const val folder2 = "../detekt-rules-coroutines" | ||
private const val configPath = "/src/main/resources/config/config.yml" | ||
|
||
@JvmStatic | ||
@BeforeAll | ||
fun init() { | ||
val args = arrayOf( | ||
"--generate-custom-rule-config", | ||
"--input", | ||
"$folder1, $folder2", | ||
) | ||
io.gitlab.arturbosch.detekt.generator.main(args) | ||
} | ||
|
||
@JvmStatic | ||
@AfterAll | ||
fun tearDown() { | ||
Files.deleteIfExists(Paths.get(folder1, configPath)) | ||
Files.deleteIfExists(Paths.get(folder2, configPath)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters