Skip to content

Commit 2f5d11d

Browse files
[autofix.ci] apply automated fixes
1 parent 0008407 commit 2f5d11d

File tree

2 files changed

+23
-33
lines changed

2 files changed

+23
-33
lines changed

libs/init/buildgen/src/mill/main/buildgen/BuildGen.scala

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ object BuildGen {
9696

9797
// extends - add Module as base if there are children but no explicit supertypes
9898
val allSupertypes = supertypes ++ mixins
99-
val effectiveSupertypes = if (allSupertypes.isEmpty && children.nonEmpty) Seq("Module") else allSupertypes
99+
val effectiveSupertypes =
100+
if (allSupertypes.isEmpty && children.nonEmpty) Seq("Module") else allSupertypes
100101
if (effectiveSupertypes.nonEmpty) {
101102
lines += renderYamlExtends(effectiveSupertypes)
102103
}
@@ -150,7 +151,10 @@ object BuildGen {
150151
// Error prone
151152
renderYamlMvnDepsList("errorProneDeps", errorProneDeps).foreach(lines += _)
152153
renderYamlStringListValuesPlain("errorProneOptions", errorProneOptions).foreach(lines += _)
153-
renderYamlStringListValues("errorProneJavacEnableOptions", errorProneJavacEnableOptions).foreach(lines += _)
154+
renderYamlStringListValues(
155+
"errorProneJavacEnableOptions",
156+
errorProneJavacEnableOptions
157+
).foreach(lines += _)
154158

155159
// Publishing
156160
renderYamlStringValue("artifactName", artifactName).foreach(lines += _)
@@ -251,14 +255,7 @@ object BuildGen {
251255
value.base.map(v => s"$name: $v")
252256
}
253257

254-
private def renderYamlRelPathValue(name: String, value: Value[os.RelPath]): Option[String] = {
255-
value.base.flatMap { v =>
256-
val s = v.toString
257-
// Empty string represents current directory - use "." instead
258-
if (s.isEmpty) Some(s"$name: .")
259-
else Some(s"$name: $s")
260-
}
261-
}
258+
262259

263260
private def renderYamlStringListValues(name: String, values: Values[Opt]): Seq[String] = {
264261
if (values.base.isEmpty) Nil
@@ -281,16 +278,13 @@ object BuildGen {
281278
}
282279
}
283280

284-
private def renderYamlPomParentProject(value: Value[Artifact]): Seq[String] = {
285-
value.base.map { artifact =>
286-
s"pomParentProject: ${artifact.group}:${artifact.id}:${artifact.version}"
287-
}.toSeq
288-
}
281+
289282

290283
private def renderYamlPomSettings(value: Value[PomSettings]): Seq[String] = {
291284
value.base.flatMap { pom =>
292285
val content = Seq.newBuilder[String]
293-
if (pom.description.nonEmpty) content += s" description: ${yamlEscapeString(pom.description)}"
286+
if (pom.description.nonEmpty)
287+
content += s" description: ${yamlEscapeString(pom.description)}"
294288
if (pom.organization.nonEmpty) content += s" organization: ${pom.organization}"
295289
if (pom.url.nonEmpty && !containsPlaceholder(pom.url)) content += s" url: ${pom.url}"
296290
if (pom.licenses.nonEmpty) {
@@ -328,22 +322,14 @@ object BuildGen {
328322

329323
private def containsPlaceholder(s: String): Boolean = s.contains("${") && s.contains("}")
330324

331-
private def renderYamlPublishProperties(values: Values[(String, String)]): Seq[String] = {
332-
if (values.base.isEmpty) Nil
333-
else {
334-
val lines = Seq.newBuilder[String]
335-
lines += "publishProperties:"
336-
for ((k, v) <- values.base) {
337-
lines += s" $k: ${yamlEscapeString(v)}"
338-
}
339-
lines.result()
340-
}
341-
}
325+
342326

343327
private def yamlEscapeString(s: String): String = {
344328
// Simple escaping for YAML strings - quote if contains special chars
345-
if (s.contains(":") || s.contains("#") || s.contains("\"") || s.contains("'") ||
346-
s.contains("\n") || s.startsWith(" ") || s.endsWith(" ") || s.contains(",")) {
329+
if (
330+
s.contains(":") || s.contains("#") || s.contains("\"") || s.contains("'") ||
331+
s.contains("\n") || s.startsWith(" ") || s.endsWith(" ") || s.contains(",")
332+
) {
347333
"\"" + s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n") + "\""
348334
} else {
349335
s
@@ -352,9 +338,11 @@ object BuildGen {
352338

353339
private def yamlEscapeStringInList(s: String): String = {
354340
// For list items, we need to quote strings containing commas, brackets, or other special chars
355-
if (s.contains(",") || s.contains("[") || s.contains("]") || s.contains(":") ||
356-
s.contains("#") || s.contains("\"") || s.contains("'") || s.contains("\n") ||
357-
s.startsWith(" ") || s.endsWith(" ")) {
341+
if (
342+
s.contains(",") || s.contains("[") || s.contains("]") || s.contains(":") ||
343+
s.contains("#") || s.contains("\"") || s.contains("'") || s.contains("\n") ||
344+
s.startsWith(" ") || s.endsWith(" ")
345+
) {
358346
"\"" + s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\n", "\\n") + "\""
359347
} else {
360348
s

runner/meta/src/mill/meta/CodeGen.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ object CodeGen {
151151
}
152152

153153
val definitions = processDataRest(data)(
154-
onProperty = (k, _) => if (k == "cross") "" else "", // Properties will be auto-implemented by AutoOverride, skip "cross"
154+
onProperty = (k, _) =>
155+
if (k == "cross") ""
156+
else "", // Properties will be auto-implemented by AutoOverride, skip "cross"
155157
onNestedObject = (k, nestedData) =>
156158
renderTemplate(s"object $k", nestedData, path :+ k)
157159
).filter(_.nonEmpty)

0 commit comments

Comments
 (0)