Skip to content

Commit 6cce59c

Browse files
authored
Refactored naming logic in cleanup.gradle.kts to be more adaptive for different naming schemes to maintain consistency (#7)
1 parent e61c047 commit 6cce59c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

buildSrc/src/main/kotlin/cleanup.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ fun String.sanitized() = replace(
6464
*/
6565
fun String.sanitizedPreservingCase() = split(regex = Regex("[^A-Za-z0-9]"))
6666
.filter { it.isNotEmpty() }
67-
.joinToString("")
67+
.joinToString("") { word ->
68+
when {
69+
word.all { it.isUpperCase() } -> word
70+
word.first().isUpperCase() -> word
71+
else -> word.replaceFirstChar { it.uppercaseChar() }
72+
}
73+
}
6874

6975
/**
7076
* [File] extension function that replaces all occurrences of `oldValue` with `newValue` in the file.

0 commit comments

Comments
 (0)