Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test common config sections pass through config validation #2135

Merged
merged 1 commit into from Nov 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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