Skip to content

Commit

Permalink
Test common config sections pass through config validation - Closes d…
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbosch authored and smyachenkov committed Dec 9, 2019
1 parent 84eff8f commit db47a3a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
Expand Up @@ -15,7 +15,13 @@ interface ValidatableConfiguration {
* We need to predefine them as the user may not have already declared an 'config'-block
* in the configuration and we want to validate the config by default.
*/
const val DEFAULT_PROPERTY_EXCLUDES = ".*>.*>excludes,.*>.*>includes,.*>.*>active,.*>.*>autoCorrect"
val DEFAULT_PROPERTY_EXCLUDES = setOf(
".*>.*>excludes",
".*>.*>includes",
".*>.*>active",
".*>.*>autoCorrect",
"build>weights.*"
).joinToString(",")

@Suppress("UNCHECKED_CAST", "ComplexMethod")
fun validateConfig(
Expand Down
Expand Up @@ -10,10 +10,14 @@ class DefaultConfigValidationSpec : Spek({

describe("default configuration is valid") {

val baseline = yamlConfig("default-detekt-config.yml")

it("is valid comparing itself") {
val baseline = yamlConfig("default-detekt-config.yml")
val result = validateConfig(baseline, baseline)
assertThat(result).isEmpty()
assertThat(validateConfig(baseline, baseline)).isEmpty()
}

it("does not flag common known config sub sections") {
assertThat(validateConfig(yamlConfig("configs/common_known_sections.yml"), baseline)).isEmpty()
}
}
})
19 changes: 19 additions & 0 deletions detekt-cli/src/test/resources/configs/common_known_sections.yml
@@ -0,0 +1,19 @@
build:
maxIssues: 10
weights:
complexity: 2
# style: 0

config:
validation: true
excludes: "test>.*"

processors:
active: true
exclude:
- 'DetektProgressListener'

console-reports:
active: true
exclude:
- 'FileBasedFindingsReport'
Expand Up @@ -6,7 +6,7 @@ title: DEFAULT_PROPERTY_EXCLUDES - detekt-api

# DEFAULT_PROPERTY_EXCLUDES

`const val DEFAULT_PROPERTY_EXCLUDES: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
`val DEFAULT_PROPERTY_EXCLUDES: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)

Known existing properties on rule's which my be absent in the default-detekt-config.yml.

Expand Down
Expand Up @@ -25,7 +25,7 @@ title: io.gitlab.arturbosch.detekt.api.internal - detekt-api
### Properties

| [ABSOLUTE_PATH](-a-b-s-o-l-u-t-e_-p-a-t-h.html) | `val ABSOLUTE_PATH: Key<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` |
| [DEFAULT_PROPERTY_EXCLUDES](-d-e-f-a-u-l-t_-p-r-o-p-e-r-t-y_-e-x-c-l-u-d-e-s.html) | Known existing properties on rule's which my be absent in the default-detekt-config.yml.`const val DEFAULT_PROPERTY_EXCLUDES: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [DEFAULT_PROPERTY_EXCLUDES](-d-e-f-a-u-l-t_-p-r-o-p-e-r-t-y_-e-x-c-l-u-d-e-s.html) | Known existing properties on rule's which my be absent in the default-detekt-config.yml.`val DEFAULT_PROPERTY_EXCLUDES: `[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [RELATIVE_PATH](-r-e-l-a-t-i-v-e_-p-a-t-h.html) | `val RELATIVE_PATH: Key<`[`String`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`>` |

### Functions
Expand Down

0 comments on commit db47a3a

Please sign in to comment.