Skip to content

Commit 8c8db07

Browse files
committed
spotless
1 parent c88d20d commit 8c8db07

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

gradle/build-plugins/src/main/kotlin/io.codemodder.core-codemods-docs.gradle.kts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ plugins {
66
id("io.codemodder.java")
77
}
88

9-
109
/**
1110
* This task generates markdown documentation for all codemods in the core-codemods project.
1211
*
@@ -19,17 +18,17 @@ val generateDocs by tasks.registering {
1918
group = "custom"
2019
description = "generate markdown docs for all codemods"
2120

22-
if(!project.properties.containsKey("codemodDocsDir")) {
21+
if (!project.properties.containsKey("codemodDocsDir")) {
2322
throw IllegalArgumentException("codemodDocsDir property is required")
2423
}
2524

2625
val codemodDocsDir = file(project.properties["codemodDocsDir"]!!)
2726
println("Using docs directory: $codemodDocsDir")
28-
if(!codemodDocsDir.exists()) {
27+
if (!codemodDocsDir.exists()) {
2928
throw IllegalArgumentException("codemodDocsDir does not exist")
3029
}
3130

32-
if(codemodDocsDir.list().isEmpty()) {
31+
if (codemodDocsDir.list().isEmpty()) {
3332
println("Docs directory was empty")
3433
}
3534

@@ -43,7 +42,7 @@ val generateDocs by tasks.registering {
4342
val codemodName = codemodFile.nameWithoutExtension
4443

4544
// check if it's in the DefaultCodemods list -- we don't do docs for the others
46-
if(!defaultCodemodSource.contains(codemodName)) {
45+
if (!defaultCodemodSource.contains(codemodName)) {
4746
println("Skipping $codemodName")
4847
continue
4948
} else {
@@ -70,15 +69,15 @@ val generateDocs by tasks.registering {
7069
.asStringLiteralExpr()
7170
.value
7271

73-
val fileName = id.replace(":","_").replace("/", "_") + ".md"
72+
val fileName = id.replace(":", "_").replace("/", "_") + ".md"
7473

7574
val importance = annotationParameters.stream()
76-
.filter { it.nameAsString == "importance" }
77-
.findFirst()
78-
.get()
79-
.value
80-
.asFieldAccessExpr()
81-
.nameAsString
75+
.filter { it.nameAsString == "importance" }
76+
.findFirst()
77+
.get()
78+
.value
79+
.asFieldAccessExpr()
80+
.nameAsString
8281

8382
val mergeGuidance = annotationParameters.stream()
8483
.filter { it.nameAsString == "reviewGuidance" }
@@ -98,19 +97,19 @@ val generateDocs by tasks.registering {
9897

9998
// add the scanning tool to the summary
10099
var needsScanningTool = "No"
101-
if(id.startsWith("sonar")) {
100+
if (id.startsWith("sonar")) {
102101
needsScanningTool = "Yes (Sonar)"
103-
} else if(id.startsWith("codeql")) {
102+
} else if (id.startsWith("codeql")) {
104103
needsScanningTool = "Yes (CodeQL)"
105-
} else if(id.startsWith("semgrep")) {
104+
} else if (id.startsWith("semgrep")) {
106105
needsScanningTool = "Yes (Semgrep)"
107106
}
108107

109108
// get the merge advice
110109
var mergeGuidanceStr = "Merge After Review"
111-
if(mergeGuidance == "ReviewGuidance.MERGE_WITHOUT_REVIEW") {
110+
if (mergeGuidance == "ReviewGuidance.MERGE_WITHOUT_REVIEW") {
112111
mergeGuidanceStr = "Merge Without Review"
113-
} else if(mergeGuidance == "ReviewGuidance.MERGE_AFTER_CURSORY_REVIEW") {
112+
} else if (mergeGuidance == "ReviewGuidance.MERGE_AFTER_CURSORY_REVIEW") {
114113
mergeGuidanceStr = "Merge After Cursory Review"
115114
}
116115

@@ -137,35 +136,35 @@ val generateDocs by tasks.registering {
137136
|-------------|----------------------|------------------------|
138137
| $importance | $mergeGuidanceStr | $needsScanningTool |
139138
140-
""".trimIndent()
139+
""".trimIndent()
141140

142141
doc += "\n$description\n"
143142

144143
val hasFaq = mergeGuidanceJustification != null || faqs != null
145144

146-
if(hasFaq) {
145+
if (hasFaq) {
147146
doc += "## F.A.Q.\n\n"
148147
}
149148

150-
if(mergeGuidanceJustification != null) {
149+
if (mergeGuidanceJustification != null) {
151150
doc += "### Why is this codemod marked as $mergeGuidanceStr?\n\n"
152151
doc += "$mergeGuidanceJustification\n\n"
153152
}
154153

155-
if(faqs != null) {
154+
if (faqs != null) {
156155
faqs as List<Map<String, String>>
157-
for(faq in faqs) {
156+
for (faq in faqs) {
158157
doc += """
159158
### ${faq["question"]}
160159
161160
${faq["answer"]}
162161
163-
""".trimIndent()
162+
""".trimIndent()
164163
doc += "\n"
165164
}
166165
}
167166

168-
doc += "\n## References\n"
167+
doc += "\n## References\n"
169168
doc += referencesStr
170169
doc += "\n" // file editors like a trailing newline
171170
codemodDocsFile.writeText(doc)

0 commit comments

Comments
 (0)