Skip to content

Commit

Permalink
Merge pull request #93 from hoc081098/renovate/com.diffplug.spotless-6.x
Browse files Browse the repository at this point in the history
chore(deps): update plugin com.diffplug.spotless to v6.7.2
  • Loading branch information
hoc081098 authored Jun 28, 2022
2 parents a71a3b6 + e0c1e9e commit 6cb17d2
Show file tree
Hide file tree
Showing 35 changed files with 283 additions and 257 deletions.
16 changes: 7 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
root = true

[*]
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

indent_size=2
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
insert_final_newline=true
[*.{kt, kts}]
ij_kotlin_imports_layout = *
disabled_rules=filename
ij_kotlin_imports_layout=*
disabled_rules=filename
63 changes: 43 additions & 20 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.MavenPublishBasePlugin
import com.vanniktech.maven.publish.SonatypeHost
import java.net.URL
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithTests
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import java.net.URL

plugins {
kotlin("multiplatform") version "1.7.0"
id("com.diffplug.spotless") version "6.6.1"
id("com.diffplug.spotless") version "6.7.2"
id("maven-publish")
id("com.vanniktech.maven.publish") version "0.20.0"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.10.1"
Expand All @@ -19,7 +19,7 @@ plugins {
}

val coroutinesVersion = "1.6.3"
val ktlintVersion = "0.44.0"
val ktlintVersion = "0.45.2"

repositories {
mavenCentral()
Expand Down Expand Up @@ -58,18 +58,22 @@ kotlin {
iosArm64()
iosArm32()
iosX64()
iosSimulatorArm64()

macosX64()
macosArm64()
mingwX64()
linuxX64()

tvosX64()
tvosSimulatorArm64()
tvosArm64()

watchosArm32()
watchosArm64()
watchosX64()
watchosX86()
watchosSimulatorArm64()

sourceSets {
val commonMain by getting {
Expand Down Expand Up @@ -112,15 +116,19 @@ kotlin {

val appleTargets = listOf(
"iosX64",
"iosSimulatorArm64",
"iosArm64",
"iosArm32",
"macosX64",
"macosArm64",
"tvosArm64",
"tvosX64",
"tvosSimulatorArm64",
"watchosArm32",
"watchosArm64",
"watchosX86",
"watchosX64",
"watchosSimulatorArm64",
"watchosX64"
)

(appleTargets + listOf("mingwX64", "linuxX64")).forEach {
Expand Down Expand Up @@ -151,20 +159,32 @@ kotlin {
}

spotless {
val EDITOR_CONFIG_KEYS: Set<String> = hashSetOf(
"ij_kotlin_imports_layout",
"indent_size",
"end_of_line",
"charset",
"continuation_indent_size"
)

kotlin {
target("**/*.kt")

ktlint(ktlintVersion).userData(
mapOf(
// TODO this should all come from editorconfig https://github.com/diffplug/spotless/issues/142
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"disabled_rules" to "filename"
)
// TODO this should all come from editorconfig https://github.com/diffplug/spotless/issues/142
val data = mapOf(
"indent_size" to "2",
"continuation_indent_size" to "4",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8",
"disabled_rules" to arrayOf("filename").joinToString(separator = ",")
)

ktlint(ktlintVersion)
.setUseExperimental(true)
.userData(data.filterKeys { it !in EDITOR_CONFIG_KEYS })
.editorConfigOverride(data.filterKeys { it in EDITOR_CONFIG_KEYS })

trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
Expand All @@ -175,14 +195,17 @@ spotless {
kotlinGradle {
target("**/*.kts")

ktlint(ktlintVersion).userData(
mapOf(
"indent_size" to "2",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8"
)
val data = mapOf(
"indent_size" to "2",
"continuation_indent_size" to "4",
"ij_kotlin_imports_layout" to "*",
"end_of_line" to "lf",
"charset" to "utf-8"
)
ktlint(ktlintVersion)
.setUseExperimental(true)
.userData(data.filterKeys { it !in EDITOR_CONFIG_KEYS })
.editorConfigOverride(data.filterKeys { it in EDITOR_CONFIG_KEYS })

trimTrailingWhitespace()
indentWithSpaces()
Expand Down
10 changes: 5 additions & 5 deletions src/commonMain/kotlin/com/hoc081098/flowext/concat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public fun <T> Flow<T>.startWith(item1: T, item2: T): Flow<T> = concat(
emit(item1)
emit(item2)
},
this,
this
)

/**
Expand All @@ -207,7 +207,7 @@ public fun <T> Flow<T>.startWith(item1: T, item2: T, item3: T): Flow<T> = concat
emit(item2)
emit(item3)
},
this,
this
)

/**
Expand All @@ -220,7 +220,7 @@ public fun <T> Flow<T>.startWith(item1: T, item2: T, item3: T, item4: T): Flow<T
emit(item3)
emit(item4)
},
this,
this
)

/**
Expand All @@ -235,7 +235,7 @@ public fun <T> Flow<T>.startWith(item1: T, item2: T, item3: T, item4: T, item5:
emit(item4)
emit(item5)
},
this,
this
)

/**
Expand All @@ -249,7 +249,7 @@ public fun <T> Flow<T>.startWith(item: T, vararg items: T): Flow<T> {
emit(it)
}
},
this,
this
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/commonMain/kotlin/com/hoc081098/flowext/eager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import kotlinx.coroutines.launch
@FlowPreview
public fun <T, R> Flow<T>.mapEager(
concurrency: Int = DEFAULT_CONCURRENCY,
transform: suspend (value: T) -> R,
transform: suspend (value: T) -> R
): Flow<R> = if (concurrency == 1) {
map(transform)
} else {
Expand Down Expand Up @@ -81,7 +81,7 @@ public fun <T, R> Flow<T>.mapEager(
public fun <T, R> Flow<T>.flatMapConcatEager(
concurrency: Int = DEFAULT_CONCURRENCY,
bufferSize: Int = Channel.BUFFERED,
transform: suspend (value: T) -> Flow<R>,
transform: suspend (value: T) -> Flow<R>
): Flow<R> = map(transform).flattenConcatEager(concurrency, bufferSize)

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public fun <T, R> Flow<T>.flatMapConcatEager(
@FlowPreview
public fun <T> Flow<Flow<T>>.flattenConcatEager(
concurrency: Int = DEFAULT_CONCURRENCY,
bufferSize: Int = Channel.BUFFERED,
bufferSize: Int = Channel.BUFFERED
): Flow<T> {
require(concurrency > 0) { "Expected positive concurrency level, but had $concurrency" }
return if (concurrency == 1) flattenConcat() else flattenConcatEagerInternal(this, concurrency, bufferSize)
Expand Down
6 changes: 3 additions & 3 deletions src/commonMain/kotlin/com/hoc081098/flowext/interval.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

package com.hoc081098.flowext

import kotlin.time.Duration
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlin.time.Duration

/**
* Returns a [Flow] that emits a 0L after the [initialDelay] and ever-increasing numbers
Expand All @@ -38,7 +38,7 @@ import kotlin.time.Duration
*/
public fun interval(
initialDelay: Duration,
period: Duration,
period: Duration
): Flow<Long> {
require(initialDelay >= Duration.ZERO) { "Expected non-negative delay, but has $initialDelay ms" }
require(period >= Duration.ZERO) { "Expected non-negative period, but has $period ms" }
Expand All @@ -63,7 +63,7 @@ public fun interval(
*/
public fun interval(
initialDelayMillis: Long,
periodMillis: Long,
periodMillis: Long
): Flow<Long> {
require(initialDelayMillis >= 0) { "Expected non-negative delay, but has $initialDelayMillis ms" }
require(periodMillis >= 0) { "Expected non-negative periodMillis, but has $periodMillis ms" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

package com.hoc081098.flowext

import kotlin.math.pow
import kotlin.time.Duration
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.retryWhen
import kotlin.math.pow
import kotlin.time.Duration

/**
* Interface that computes the delay between retries.
Expand Down Expand Up @@ -87,7 +87,7 @@ public fun interface DelayStrategy {
public class ExponentialBackoffDelayStrategy(
private val initialDelay: Duration,
private val factor: Double,
private val maxDelay: Duration,
private val maxDelay: Duration
) : DelayStrategy {
override fun nextDelay(cause: Throwable, attempt: Long): Duration =
(if (attempt <= 0L) initialDelay else initialDelay * factor.pow(attempt.toDouble()))
Expand Down Expand Up @@ -133,9 +133,9 @@ public fun <T> Flow<T>.retryWhenWithExponentialBackoff(
strategy = DelayStrategy.ExponentialBackoffDelayStrategy(
initialDelay = initialDelay,
factor = factor,
maxDelay = maxDelay,
maxDelay = maxDelay
),
predicate = predicate,
predicate = predicate
)

/**
Expand Down
10 changes: 5 additions & 5 deletions src/commonMain/kotlin/com/hoc081098/flowext/throttle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import com.hoc081098.flowext.ThrottleConfiguration.LEADING_AND_TRAILING
import com.hoc081098.flowext.ThrottleConfiguration.TRAILING
import com.hoc081098.flowext.internal.DONE_VALUE
import com.hoc081098.flowext.utils.NULL_VALUE
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancelAndJoin
Expand All @@ -41,8 +43,6 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch
import kotlinx.coroutines.selects.select
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds

/**
* Define leading and trailing behavior.
Expand Down Expand Up @@ -123,7 +123,7 @@ private inline val ThrottleConfiguration.isTrailing: Boolean
@ExperimentalCoroutinesApi
public fun <T> Flow<T>.throttleTime(
duration: Duration,
throttleConfiguration: ThrottleConfiguration = LEADING,
throttleConfiguration: ThrottleConfiguration = LEADING
): Flow<T> = throttleTime(throttleConfiguration) { duration }

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ public fun <T> Flow<T>.throttleTime(
@ExperimentalCoroutinesApi
public fun <T> Flow<T>.throttleTime(
timeMillis: Long,
throttleConfiguration: ThrottleConfiguration = LEADING,
throttleConfiguration: ThrottleConfiguration = LEADING
): Flow<T> = throttleTime(throttleConfiguration) { timeMillis.milliseconds }

/**
Expand Down Expand Up @@ -233,7 +233,7 @@ public fun <T> Flow<T>.throttleTime(
@ExperimentalCoroutinesApi
public fun <T> Flow<T>.throttleTime(
throttleConfiguration: ThrottleConfiguration = LEADING,
durationSelector: (value: T) -> Duration,
durationSelector: (value: T) -> Duration
): Flow<T> = flow {
val leading = throttleConfiguration.isLeading
val trailing = throttleConfiguration.isTrailing
Expand Down
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/com/hoc081098/flowext/timer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

package com.hoc081098.flowext

import kotlin.time.Duration
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlin.time.Duration

/**
* Creates a [Flow] that will wait for a specified time, before emitting the [value].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public fun <A, B, R> Flow<A>.withLatestFrom(
transform(
value,
NULL_VALUE.unbox(otherRef.value ?: return@collect)
),
)
)
}
}
Expand Down
Loading

0 comments on commit 6cb17d2

Please sign in to comment.