Skip to content

Commit

Permalink
fix: code style, according to new version of kt-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gciatto committed Jan 2, 2024
1 parent 8aa438a commit 8121086
Show file tree
Hide file tree
Showing 32 changed files with 2,439 additions and 1,493 deletions.
7 changes: 5 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
root = true

[*.{kt,kts}]
ktlint_disabled_rules=import-ordering
max_line_length=120
max_line_length = 120
ktlint_standard_property-naming = disabled
# ktlint_standard_discouraged-comment-location = disabled
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin = "1.9.22"
jvm = "1.8"
node = "16-latest"
ktMpp = "4.0.3"
ktMpp = "4.1.0"

[libraries]
kotlin-reflect = { module = "org.jetbrains.kotlin:kotlin-reflect", version.ref = "kotlin" }
Expand Down
6 changes: 4 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}

fun tag(format: String, vararg properties: String): String =
format.format(*properties.map { System.getProperty(it) ?: error("Missing property $it") }.toTypedArray())
fun tag(
format: String,
vararg properties: String,
): String = format.format(*properties.map { System.getProperty(it) ?: error("Missing property $it") }.toTypedArray())

val ci = !System.getenv("CI").isNullOrBlank()
val ciTag = if (ci) "CI" else "Local"
Expand Down
106 changes: 79 additions & 27 deletions src/commonMain/kotlin/org/gciatto/kt/math/BigDecimal.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("plusWithContext")
fun plus(augend: BigDecimal?, mc: MathContext): BigDecimal
fun plus(
augend: BigDecimal?,
mc: MathContext,
): BigDecimal

/**
* Returns a [BigDecimal] whose value is `(this -
Expand Down Expand Up @@ -119,7 +122,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("minusWithContext")
fun minus(subtrahend: BigDecimal, mc: MathContext): BigDecimal
fun minus(
subtrahend: BigDecimal,
mc: MathContext,
): BigDecimal

/**
* Returns a [BigDecimal] whose value is `(this
Expand All @@ -144,7 +150,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("timesWithContext")
fun times(multiplicand: BigDecimal, mc: MathContext): BigDecimal
fun times(
multiplicand: BigDecimal,
mc: MathContext,
): BigDecimal

/**
* Returns a [BigDecimal] whose value is `(this /
Expand Down Expand Up @@ -177,7 +186,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("divWithContext")
fun div(divisor: BigDecimal, mc: MathContext): BigDecimal?
fun div(
divisor: BigDecimal,
mc: MathContext,
): BigDecimal?

/**
* Returns a [BigDecimal] whose value is the integer part
Expand Down Expand Up @@ -214,7 +226,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @author Joseph D. Darcy
*/
@JsName("divideToIntegralValueWithContext")
fun divideToIntegralValue(divisor: BigDecimal, mc: MathContext): BigDecimal
fun divideToIntegralValue(
divisor: BigDecimal,
mc: MathContext,
): BigDecimal

/**
* Returns a [BigDecimal] whose value is `(this % divisor)`.
Expand Down Expand Up @@ -259,7 +274,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("remWithContext")
fun rem(divisor: BigDecimal, mc: MathContext): BigDecimal
fun rem(
divisor: BigDecimal,
mc: MathContext,
): BigDecimal

/**
* Returns a two-element [BigDecimal] array containing the
Expand Down Expand Up @@ -313,7 +331,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("divideAndRemainderWithContext")
fun divideAndRemainder(divisor: BigDecimal, mc: MathContext): Pair<BigDecimal, BigDecimal>
fun divideAndRemainder(
divisor: BigDecimal,
mc: MathContext,
): Pair<BigDecimal, BigDecimal>

/**
* Returns an approximation to the square root of `this`
Expand Down Expand Up @@ -423,7 +444,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("powWithContext")
fun pow(n: Int, mc: MathContext): BigDecimal?
fun pow(
n: Int,
mc: MathContext,
): BigDecimal?

/**
* Returns a [BigDecimal] whose value is the absolute value
Expand Down Expand Up @@ -546,7 +570,10 @@ interface BigDecimal : Comparable<BigDecimal> {
* @since 1.5
*/
@JsName("setScaleRounding")
fun setScale(newScale: Int, roundingMode: RoundingMode): BigDecimal
fun setScale(
newScale: Int,
roundingMode: RoundingMode,
): BigDecimal

/**
* Returns a [BigDecimal] whose _scale is the specified
Expand Down Expand Up @@ -593,10 +620,13 @@ interface BigDecimal : Comparable<BigDecimal> {
* @see .ROUND_UNNECESSARY
*/
@Deprecated(
"The method {@link #setScale(int, RoundingMode)} should be used in preference to this legacy method."
"The method {@link #setScale(int, RoundingMode)} should be used in preference to this legacy method.",
)
@JsName("setScaleInt")
fun setScale(newScale: Int, roundingMode: Int): BigDecimal
fun setScale(
newScale: Int,
roundingMode: Int,
): BigDecimal

/**
* Returns a [BigDecimal] whose _scale is the specified
Expand Down Expand Up @@ -870,7 +900,6 @@ interface BigDecimal : Comparable<BigDecimal> {
* @return this [BigDecimal] converted to a `long`.
* @jls 5.1.3 Narrowing Primitive Conversion
*/
/*override*/
@JsName("toLong")
fun toLong(): Long

Expand Down Expand Up @@ -906,19 +935,15 @@ interface BigDecimal : Comparable<BigDecimal> {
* @return this [BigDecimal] converted to an `int`.
* @jls 5.1.3 Narrowing Primitive Conversion
*/
/*override*/
@JsName("toInt")
fun toInt(): Int

/*override*/
@JsName("toByte")
fun toByte(): Byte

/*override*/
@JsName("toChar")
fun toChar(): Char

/*override*/
@JsName("toShort")
fun toShort(): Short

Expand Down Expand Up @@ -983,7 +1008,6 @@ interface BigDecimal : Comparable<BigDecimal> {
* @return this [BigDecimal] converted to a `float`.
* @jls 5.1.3 Narrowing Primitive Conversion
*/
/*override*/
@JsName("toFloat")
fun toFloat(): Float

Expand All @@ -1003,7 +1027,6 @@ interface BigDecimal : Comparable<BigDecimal> {
* @return this [BigDecimal] converted to a `double`.
* @jls 5.1.3 Narrowing Primitive Conversion
*/
/*override*/
@JsName("toDouble")
fun toDouble(): Double

Expand Down Expand Up @@ -1093,7 +1116,10 @@ interface BigDecimal : Comparable<BigDecimal> {
*/
@JvmStatic
@JsName("ofScaledLong")
fun of(unscaledVal: Long, scale: Int): BigDecimal = bigDecimalOf(unscaledVal, scale)
fun of(
unscaledVal: Long,
scale: Int,
): BigDecimal = bigDecimalOf(unscaledVal, scale)

/**
* Translates a `long` value into a [BigDecimal]
Expand All @@ -1108,7 +1134,11 @@ interface BigDecimal : Comparable<BigDecimal> {
*/
@JvmStatic
@JsName("ofScaledLongWithPrecision")
fun of(unscaledVal: Long, scale: Int, prec: Int): BigDecimal = bigDecimalOf(unscaledVal, scale, prec)
fun of(
unscaledVal: Long,
scale: Int,
prec: Int,
): BigDecimal = bigDecimalOf(unscaledVal, scale, prec)

@JvmStatic
@JsName("ofInt")
Expand All @@ -1120,7 +1150,11 @@ interface BigDecimal : Comparable<BigDecimal> {

@JvmStatic
@JsName("ofScaledBigIntegerWithPrecision")
fun of(intVal: BigInteger, scale: Int, prec: Int): BigDecimal = bigDecimalOf(intVal, scale, prec)
fun of(
intVal: BigInteger,
scale: Int,
prec: Int,
): BigDecimal = bigDecimalOf(intVal, scale, prec)

/**
* Translates a `double` into a [BigDecimal], using
Expand All @@ -1141,29 +1175,47 @@ interface BigDecimal : Comparable<BigDecimal> {
@JvmStatic
@JsName("ofDouble")
@JvmOverloads
fun of(`val`: Double, ctx: MathContext? = null): BigDecimal = bigDecimalOf(`val`, ctx)
fun of(
`val`: Double,
ctx: MathContext? = null,
): BigDecimal = bigDecimalOf(`val`, ctx)

@JvmStatic
@JsName("ofFloat")
@JvmOverloads
fun of(`val`: Float, ctx: MathContext? = null): BigDecimal = bigDecimalOf(`val`, ctx)
fun of(
`val`: Float,
ctx: MathContext? = null,
): BigDecimal = bigDecimalOf(`val`, ctx)

@JvmStatic
@JsName("parse")
@JvmOverloads
fun of(`val`: String, ctx: MathContext? = null): BigDecimal = bigDecimalOf(`val`, ctx)
fun of(
`val`: String,
ctx: MathContext? = null,
): BigDecimal = bigDecimalOf(`val`, ctx)

@JvmStatic
@JsName("ofBigInteger")
@JvmOverloads
fun of(`val`: BigInteger, ctx: MathContext? = null): BigDecimal = bigDecimalOf(`val`, ctx)
fun of(
`val`: BigInteger,
ctx: MathContext? = null,
): BigDecimal = bigDecimalOf(`val`, ctx)

@JvmStatic
@JsName("ofIntWithContext")
fun of(`val`: Int, ctx: MathContext): BigDecimal = bigDecimalOf(`val`, ctx)
fun of(
`val`: Int,
ctx: MathContext,
): BigDecimal = bigDecimalOf(`val`, ctx)

@JvmStatic
@JsName("ofWithContext")
fun of(`val`: Long, ctx: MathContext): BigDecimal = bigDecimalOf(`val`, ctx)
fun of(
`val`: Long,
ctx: MathContext,
): BigDecimal = bigDecimalOf(`val`, ctx)
}
}
35 changes: 22 additions & 13 deletions src/commonMain/kotlin/org/gciatto/kt/math/BigInteger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ interface BigInteger : Comparable<BigInteger> {
* @see .modInverse
*/
@JsName("modPow")
fun modPow(exponent: BigInteger, modulus: BigInteger): BigInteger
fun modPow(
exponent: BigInteger,
modulus: BigInteger,
): BigInteger

/**
* Returns a BigInteger whose value is `(this`<sup>-1</sup> `rem m)`.
Expand Down Expand Up @@ -428,7 +431,10 @@ interface BigInteger : Comparable<BigInteger> {
operator fun get(n: Int): Boolean

@JsName("set")
operator fun set(n: Int, b: Boolean): BigInteger
operator fun set(
n: Int,
b: Boolean,
): BigInteger

/**
* Returns a BigInteger whose value is equivalent to this BigInteger
Expand Down Expand Up @@ -592,7 +598,6 @@ interface BigInteger : Comparable<BigInteger> {
* @see BigInteger.toIntExact
* @jls 5.1.3 Narrowing Primitive Conversion
*/
/*override*/
@JsName("toInt")
fun toInt(): Int

Expand All @@ -612,27 +617,21 @@ interface BigInteger : Comparable<BigInteger> {
* @see .toLongExact
* @jls 5.1.3 Narrowing Primitive Conversion
*/
/*override*/
@JsName("toLong")
fun toLong(): Long

/*override*/
@JsName("toByte")
fun toByte(): Byte

/*override*/
@JsName("toChar")
fun toChar(): Char

/*override*/
@JsName("toShort")
fun toShort(): Short

/*override*/
@JsName("toFloat")
fun toFloat(): Float

/*override*/
@JsName("toDouble")
fun toDouble(): Double

Expand Down Expand Up @@ -758,7 +757,10 @@ interface BigInteger : Comparable<BigInteger> {
*/
@JvmStatic
@JsName("probablePrime")
fun probablePrime(bitLength: Int, rnd: Random): BigInteger = bigProbablePrimeInteger(bitLength, rnd)
fun probablePrime(
bitLength: Int,
rnd: Random,
): BigInteger = bigProbablePrimeInteger(bitLength, rnd)

/**
* Returns a BigInteger whose value is equal to that of the
Expand All @@ -785,7 +787,10 @@ interface BigInteger : Comparable<BigInteger> {

@JsName("parseWithRadix")
@JvmStatic
fun of(value: String, radix: Int): BigInteger = bigIntegerOf(value, radix)
fun of(
value: String,
radix: Int,
): BigInteger = bigIntegerOf(value, radix)

/**
* Returns a BigInteger with the given two's complement representation.
Expand All @@ -797,7 +802,11 @@ interface BigInteger : Comparable<BigInteger> {
fun of(value: IntArray): BigInteger = bigIntegerOf(value)

@JsName("ofSlideIntArray")
fun of(signum: Int, magnitude: ByteArray, off: Int, len: Int): BigInteger =
bigIntegerOf(signum, magnitude, off, len)
fun of(
signum: Int,
magnitude: ByteArray,
off: Int,
len: Int,
): BigInteger = bigIntegerOf(signum, magnitude, off, len)
}
}
Loading

0 comments on commit 8121086

Please sign in to comment.