-
-
Notifications
You must be signed in to change notification settings - Fork 767
/
Exclusion.kt
68 lines (55 loc) · 2.1 KB
/
Exclusion.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package io.gitlab.arturbosch.detekt.generator.printer.defaultconfig
import io.gitlab.arturbosch.detekt.generator.collection.Rule
/**
* Holds a list of extra exclusions for rules and rule sets.
*/
val exclusions = arrayOf(TestExclusions, KotlinScriptExclusions, KotlinScriptAndTestExclusions, LibraryExclusions)
/**
* Tracks rules and rule sets which needs an extra `excludes: $pattern` property
* when printing the default detekt config yaml file.
*/
abstract class Exclusions {
abstract val pattern: String
open val ruleSets: Set<String> = emptySet()
abstract val rules: Set<String>
fun isExcluded(rule: Rule) = rule.name in rules || rule.inMultiRule in rules
}
private object TestExclusions : Exclusions() {
override val pattern =
"['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']"
override val ruleSets = emptySet<String>()
override val rules = setOf(
"FunctionNaming",
"LateinitUsage",
"StringLiteralDuplication",
"SpreadOperator",
"TooManyFunctions",
"ForEachOnRange",
"TooGenericExceptionCaught",
"InstanceOfCheckForException",
"ThrowingExceptionsWithoutMessageOrCause",
"UndocumentedPublicClass",
"UndocumentedPublicFunction",
"UndocumentedPublicProperty",
"UnsafeCallOnNullableType",
"KDocReferencesNonPublicProperty",
)
}
private object KotlinScriptExclusions : Exclusions() {
override val pattern = "['**/*.kts']"
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 = "['**']"
override val rules = setOf(
"ForbiddenPublicDataClass",
"LibraryCodeMustSpecifyReturnType",
"LibraryEntitiesShouldNotBePublic",
)
}