forked from detekt/detekt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigPrinter.kt
86 lines (77 loc) · 2.65 KB
/
ConfigPrinter.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package io.gitlab.arturbosch.detekt.generator.printer.defaultconfig
import io.github.detekt.utils.yaml
import io.gitlab.arturbosch.detekt.generator.collection.RuleSetPage
import io.gitlab.arturbosch.detekt.generator.printer.DocumentationPrinter
object ConfigPrinter : DocumentationPrinter<List<RuleSetPage>> {
override fun print(item: List<RuleSetPage>): String {
return yaml {
yaml { defaultBuildConfiguration() }
emptyLine()
yaml { defaultConfigConfiguration() }
emptyLine()
yaml { defaultProcessorsConfiguration() }
emptyLine()
yaml { defaultConsoleReportsConfiguration() }
emptyLine()
yaml { defaultOutputReportsConfiguration() }
emptyLine()
item.sortedBy { it.ruleSet.name }
.forEach { printRuleSetPage(it) }
}
}
private fun defaultBuildConfiguration(): String = """
build:
maxIssues: 0
excludeCorrectable: false
weights:
# complexity: 2
# LongParameterList: 1
# style: 1
# comments: 1
""".trimIndent()
private fun defaultConfigConfiguration(): String = """
config:
validation: true
warningsAsErrors: false
# when writing own rules with new properties, exclude the property path e.g.: 'my_rule_set,.*>.*>[my_property]'
excludes: ''
""".trimIndent()
private fun defaultProcessorsConfiguration(): String = """
processors:
active: true
exclude:
- 'DetektProgressListener'
# - 'KtFileCountProcessor'
# - 'PackageCountProcessor'
# - 'ClassCountProcessor'
# - 'FunctionCountProcessor'
# - 'PropertyCountProcessor'
# - 'ProjectComplexityProcessor'
# - 'ProjectCognitiveComplexityProcessor'
# - 'ProjectLLOCProcessor'
# - 'ProjectCLOCProcessor'
# - 'ProjectLOCProcessor'
# - 'ProjectSLOCProcessor'
# - 'LicenseHeaderLoaderExtension'
""".trimIndent()
private fun defaultConsoleReportsConfiguration(): String = """
console-reports:
active: true
exclude:
- 'ProjectStatisticsReport'
- 'ComplexityReport'
- 'NotificationReport'
- 'FindingsReport'
- 'FileBasedFindingsReport'
# - 'LiteFindingsReport'
""".trimIndent()
private fun defaultOutputReportsConfiguration(): String = """
output-reports:
active: true
exclude:
# - 'TxtOutputReport'
# - 'XmlOutputReport'
# - 'HtmlOutputReport'
# - 'MdOutputReport'
""".trimIndent()
}