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

Update MagicNumber rule to exclude .kts files #4877

Merged
merged 2 commits into from May 31, 2022
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
2 changes: 1 addition & 1 deletion detekt-core/src/main/resources/default-detekt-config.yml
Expand Up @@ -543,7 +543,7 @@ style:
maxJumpCount: 1
MagicNumber:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', '**/*.kts']
ignoreNumbers:
- '-1'
- '0'
Expand Down
Expand Up @@ -5,7 +5,7 @@ import io.gitlab.arturbosch.detekt.generator.collection.Rule
/**
* Holds a list of extra exclusions for rules and rule sets.
*/
val exclusions = arrayOf(TestExclusions, KotlinScriptExclusions, LibraryExclusions)
val exclusions = arrayOf(TestExclusions, KotlinScriptExclusions, KotlinScriptAndTestExclusions, LibraryExclusions)

/**
* Tracks rules and rule sets which needs an extra `excludes: $pattern` property
Expand All @@ -28,7 +28,6 @@ private object TestExclusions : Exclusions() {
override val rules = setOf(
"FunctionNaming",
"WildcardImport",
"MagicNumber",
"LateinitUsage",
"StringLiteralDuplication",
"SpreadOperator",
Expand All @@ -51,6 +50,14 @@ private object KotlinScriptExclusions : Exclusions() {
override val rules = setOf("MissingPackageDeclaration")
}

private object KotlinScriptAndTestExclusions : Exclusions() {

override val pattern =
"['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**', " +
"'**/*.kts']"
override val rules = setOf("MagicNumber")
}

private object LibraryExclusions : Exclusions() {

override val pattern = "['**']"
Expand Down