Skip to content

Commit

Permalink
Remove usage of String.format
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival committed Dec 24, 2024
1 parent b38b797 commit 1627ddf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ object StringEscapeUtils {
// '\u0020'..'\u007E' are printable ASCII characters
ESCAPE_MAP[char]
?: if (char !in '\u0020'..'\u007E') {
"\\u%04x".format(char.code)
@Suppress("MagicNumber")
"\\u${char.code.toString(HEX_RADIX).padStart(4, '0')}"
} else {
char
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package org.cqframework.cql.cql2elm

import java.util.*
import kotlin.collections.ArrayList
import org.cqframework.cql.cql2elm.model.Invocation
import org.cqframework.cql.cql2elm.model.invocation.*
Expand Down Expand Up @@ -124,12 +123,11 @@ class SystemFunctionResolver(private val builder: LibraryBuilder) {
when {
dateConversion != null && dateTimeConversion != null -> {
require(dateConversion.score != dateTimeConversion.score) {
"Ambiguous implicit conversion from %s to %s or %s."
.format(
op.resultType.toString(),
dateConversion.toType.toString(),
dateTimeConversion.toType.toString()
)
"""Ambiguous implicit conversion from
|${op.resultType} to ${dateConversion.toType}
|or ${dateTimeConversion}."""
.trimMargin()
.replace("\n", "")
}

if (dateConversion.score < dateTimeConversion.score) {
Expand Down Expand Up @@ -711,7 +709,7 @@ class SystemFunctionResolver(private val builder: LibraryBuilder) {

private fun checkNumberOfOperands(functionRef: FunctionRef, expectedOperands: Int) {
require(functionRef.operand.size == expectedOperands) {
"Could not resolve call to system operator ${functionRef.name}. Expected ${expectedOperands} arguments."
"Could not resolve call to system operator ${functionRef.name}. Expected $expectedOperands arguments."
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.hl7.cql.model

import java.util.*

data class ClassTypeElement(
val name: String,
val type: DataType,
Expand All @@ -21,11 +19,11 @@ data class ClassTypeElement(
this.name == that.name && type.isSuperTypeOf(that.type)

override fun toString(): String {
return "$name:$type$%s%s%s"
.format(
if (this.prohibited) " (prohibited)" else "",
if (this.oneBased) " (one-based)" else "",
if (this.target != null) " (target: " + this.target + ")" else ""
)
return """$name:$type
|${if (this.prohibited) " (prohibited)" else ""}
|${if (this.oneBased) " (one-based)" else ""}
|${if (this.target != null) " (target: " + this.target + ")" else ""}"""
.trimMargin()
.replace("\n", "")
}
}

0 comments on commit 1627ddf

Please sign in to comment.