Skip to content

Commit 5c4635b

Browse files
committed
Reformat project
1 parent 104f6a8 commit 5c4635b

File tree

16 files changed

+50
-28
lines changed

16 files changed

+50
-28
lines changed

example/src/main/kotlin/com/github/michaelbull/result/example/Application.kt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,17 @@ import io.ktor.server.routing.post
4545
import io.ktor.server.routing.routing
4646

4747
fun main() {
48-
embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
49-
configureSerialization()
50-
configureRouting()
51-
}.start(wait = true)
48+
embeddedServer(
49+
factory = Netty,
50+
port = 8080,
51+
host = "0.0.0.0",
52+
module = Application::exampleModule
53+
).start(wait = true)
54+
}
55+
56+
fun Application.exampleModule() {
57+
configureSerialization()
58+
configureRouting()
5259
}
5360

5461
fun Application.configureSerialization() {
@@ -111,7 +118,8 @@ private fun messageToResponse(message: DomainMessage) = when (message) {
111118
LastNameTooLong,
112119
EmailRequired,
113120
EmailTooLong,
114-
EmailInvalid ->
121+
EmailInvalid,
122+
->
115123
HttpStatusCode.BadRequest to "There is an error in your request"
116124

117125
// exposed errors
@@ -121,7 +129,8 @@ private fun messageToResponse(message: DomainMessage) = when (message) {
121129
// internal errors
122130
SqlCustomerInvalid,
123131
DatabaseTimeout,
124-
is DatabaseError ->
132+
is DatabaseError,
133+
->
125134
HttpStatusCode.InternalServerError to "Internal server error occurred"
126135
}
127136

example/src/main/kotlin/com/github/michaelbull/result/example/model/domain/Customer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package com.github.michaelbull.result.example.model.domain
22

33
data class Customer(
44
val name: PersonalName,
5-
val email: EmailAddress
5+
val email: EmailAddress,
66
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.github.michaelbull.result.example.model.domain
22

33
data class EmailAddress(
4-
val address: String
4+
val address: String,
55
)

example/src/main/kotlin/com/github/michaelbull/result/example/model/domain/PersonalName.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ package com.github.michaelbull.result.example.model.domain
22

33
data class PersonalName(
44
val first: String,
5-
val last: String
5+
val last: String,
66
)

example/src/main/kotlin/com/github/michaelbull/result/example/model/dto/CustomerDto.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package com.github.michaelbull.result.example.model.dto
33
data class CustomerDto(
44
val firstName: String,
55
val lastName: String,
6-
val email: String
6+
val email: String,
77
)

example/src/main/kotlin/com/github/michaelbull/result/example/model/entity/CustomerEntity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ data class CustomerEntity(
88
val id: CustomerId,
99
val firstName: String,
1010
val lastName: String,
11-
val email: String
11+
val email: String,
1212
)

example/src/main/kotlin/com/github/michaelbull/result/example/repository/InMemoryCustomerRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import com.github.michaelbull.result.example.model.entity.CustomerId
55
import java.sql.SQLTimeoutException
66

77
class InMemoryCustomerRepository(
8-
private val customers: MutableMap<CustomerId, CustomerEntity>
8+
private val customers: MutableMap<CustomerId, CustomerEntity>,
99
) : CustomerRepository {
1010

1111
override fun findById(id: CustomerId): CustomerEntity? {

example/src/main/kotlin/com/github/michaelbull/result/example/service/CustomerService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.github.michaelbull.result.zip
2929
import java.sql.SQLTimeoutException
3030

3131
class CustomerService(
32-
private val repository: CustomerRepository
32+
private val repository: CustomerRepository,
3333
) {
3434

3535
fun getById(id: Long): Result<CustomerDto, DomainMessage> {

kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public interface SuspendableResultBinding<E> : CoroutineScope {
4545

4646
@PublishedApi
4747
internal class SuspendableResultBindingImpl<E>(
48-
override val coroutineContext: CoroutineContext
48+
override val coroutineContext: CoroutineContext,
4949
) : SuspendableResultBinding<E> {
5050

5151
private val mutex = Mutex()

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Iterable.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public fun <V, E> Iterable<Result<V, E>>.partition(): Pair<List<V>, List<E>> {
138138
* transformation fails. Elements in the returned list are in the input [Iterable] order.
139139
*/
140140
public inline fun <V, E, U> Iterable<V>.mapResult(
141-
transform: (V) -> Result<U, E>
141+
transform: (V) -> Result<U, E>,
142142
): Result<List<U>, E> {
143143
return Ok(map { element ->
144144
when (val transformed = transform(element)) {
@@ -155,7 +155,7 @@ public inline fun <V, E, U> Iterable<V>.mapResult(
155155
*/
156156
public inline fun <V, E, U, C : MutableCollection<in U>> Iterable<V>.mapResultTo(
157157
destination: C,
158-
transform: (V) -> Result<U, E>
158+
transform: (V) -> Result<U, E>,
159159
): Result<C, E> {
160160
return Ok(mapTo(destination) { element ->
161161
when (val transformed = transform(element)) {
@@ -172,7 +172,7 @@ public inline fun <V, E, U, C : MutableCollection<in U>> Iterable<V>.mapResultTo
172172
* order.
173173
*/
174174
public inline fun <V, E, U : Any> Iterable<V>.mapResultNotNull(
175-
transform: (V) -> Result<U, E>?
175+
transform: (V) -> Result<U, E>?,
176176
): Result<List<U>, E> {
177177
return Ok(mapNotNull { element ->
178178
when (val transformed = transform(element)) {
@@ -190,7 +190,7 @@ public inline fun <V, E, U : Any> Iterable<V>.mapResultNotNull(
190190
*/
191191
public inline fun <V, E, U : Any, C : MutableCollection<in U>> Iterable<V>.mapResultNotNullTo(
192192
destination: C,
193-
transform: (V) -> Result<U, E>?
193+
transform: (V) -> Result<U, E>?,
194194
): Result<C, E> {
195195
return Ok(mapNotNullTo(destination) { element ->
196196
when (val transformed = transform(element)) {
@@ -208,7 +208,7 @@ public inline fun <V, E, U : Any, C : MutableCollection<in U>> Iterable<V>.mapRe
208208
* order.
209209
*/
210210
public inline fun <V, E, U> Iterable<V>.mapResultIndexed(
211-
transform: (index: Int, V) -> Result<U, E>
211+
transform: (index: Int, V) -> Result<U, E>,
212212
): Result<List<U>, E> {
213213
return Ok(mapIndexed { index, element ->
214214
when (val transformed = transform(index, element)) {
@@ -225,7 +225,7 @@ public inline fun <V, E, U> Iterable<V>.mapResultIndexed(
225225
*/
226226
public inline fun <V, E, U, C : MutableCollection<in U>> Iterable<V>.mapResultIndexedTo(
227227
destination: C,
228-
transform: (index: Int, V) -> Result<U, E>
228+
transform: (index: Int, V) -> Result<U, E>,
229229
): Result<C, E> {
230230
return Ok(mapIndexedTo(destination) { index, element ->
231231
when (val transformed = transform(index, element)) {
@@ -242,7 +242,7 @@ public inline fun <V, E, U, C : MutableCollection<in U>> Iterable<V>.mapResultIn
242242
* the input [Iterable] order.
243243
*/
244244
public inline fun <V, E, U : Any> Iterable<V>.mapResultIndexedNotNull(
245-
transform: (index: Int, V) -> Result<U, E>?
245+
transform: (index: Int, V) -> Result<U, E>?,
246246
): Result<List<U>, E> {
247247
return Ok(mapIndexedNotNull { index, element ->
248248
when (val transformed = transform(index, element)) {
@@ -260,7 +260,7 @@ public inline fun <V, E, U : Any> Iterable<V>.mapResultIndexedNotNull(
260260
*/
261261
public inline fun <V, E, U : Any, C : MutableCollection<in U>> Iterable<V>.mapResultIndexedNotNullTo(
262262
destination: C,
263-
transform: (index: Int, V) -> Result<U, E>?
263+
transform: (index: Int, V) -> Result<U, E>?,
264264
): Result<C, E> {
265265
return Ok(mapIndexedNotNullTo(destination) { index, element ->
266266
when (val transformed = transform(index, element)) {

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Recover.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public inline fun <V, E> Result<V, E>.andThenRecover(transform: (E) -> Result<V,
100100
*/
101101
public inline fun <V, E> Result<V, E>.andThenRecoverIf(
102102
predicate: (E) -> Boolean,
103-
transform: (E) -> Result<V, E>
103+
transform: (E) -> Result<V, E>,
104104
): Result<V, E> {
105105
contract {
106106
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)
@@ -123,7 +123,7 @@ public inline fun <V, E> Result<V, E>.andThenRecoverIf(
123123
*/
124124
public inline fun <V, E> Result<V, E>.andThenRecoverUnless(
125125
predicate: (E) -> Boolean,
126-
transform: (E) -> Result<V, E>
126+
transform: (E) -> Result<V, E>,
127127
): Result<V, E> {
128128
contract {
129129
callsInPlace(predicate, InvocationKind.AT_MOST_ONCE)

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Zip.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private typealias Producer<T, E> = () -> Result<T, E>
1414
public inline fun <T1, T2, E, V> zip(
1515
producer1: Producer<T1, E>,
1616
producer2: Producer<T2, E>,
17-
transform: (T1, T2) -> V
17+
transform: (T1, T2) -> V,
1818
): Result<V, E> {
1919
contract {
2020
callsInPlace(producer1, InvocationKind.EXACTLY_ONCE)
@@ -39,7 +39,7 @@ public inline fun <T1, T2, T3, E, V> zip(
3939
producer1: Producer<T1, E>,
4040
producer2: Producer<T2, E>,
4141
producer3: Producer<T3, E>,
42-
transform: (T1, T2, T3) -> V
42+
transform: (T1, T2, T3) -> V,
4343
): Result<V, E> {
4444
contract {
4545
callsInPlace(producer1, InvocationKind.EXACTLY_ONCE)
@@ -68,7 +68,7 @@ public inline fun <T1, T2, T3, T4, E, V> zip(
6868
producer2: Producer<T2, E>,
6969
producer3: Producer<T3, E>,
7070
producer4: Producer<T4, E>,
71-
transform: (T1, T2, T3, T4) -> V
71+
transform: (T1, T2, T3, T4) -> V,
7272
): Result<V, E> {
7373
contract {
7474
callsInPlace(producer1, InvocationKind.EXACTLY_ONCE)
@@ -101,7 +101,7 @@ public inline fun <T1, T2, T3, T4, T5, E, V> zip(
101101
producer3: Producer<T3, E>,
102102
producer4: Producer<T4, E>,
103103
producer5: Producer<T5, E>,
104-
transform: (T1, T2, T3, T4, T5) -> V
104+
transform: (T1, T2, T3, T4, T5) -> V,
105105
): Result<V, E> {
106106
contract {
107107
callsInPlace(producer1, InvocationKind.EXACTLY_ONCE)

kotlin-result/src/commonTest/kotlin/com/github/michaelbull/result/FactoryTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlin.test.Test
44
import kotlin.test.assertEquals
55

66
class FactoryTest {
7+
78
class RunCatching {
89

910
@Test

kotlin-result/src/commonTest/kotlin/com/github/michaelbull/result/GetTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import kotlin.test.assertNull
77

88
@Suppress("IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION")
99
class GetTest {
10+
1011
class Get {
12+
1113
@Test
1214
fun returnsValueIfOk() {
1315
assertEquals(
@@ -23,6 +25,7 @@ class GetTest {
2325
}
2426

2527
class GetError {
28+
2629
@Test
2730
fun returnsNullIfOk() {
2831
assertNull(Ok("example").getError())
@@ -38,6 +41,7 @@ class GetTest {
3841
}
3942

4043
class GetOr {
44+
4145
@Test
4246
fun returnsValueIfOk() {
4347
assertEquals(
@@ -56,6 +60,7 @@ class GetTest {
5660
}
5761

5862
class GetOrThrow {
63+
5964
@Test
6065
fun returnsValueIfOk() {
6166
assertEquals(
@@ -75,6 +80,7 @@ class GetTest {
7580
}
7681

7782
class GetOrThrowWithTransform {
83+
7884
@Test
7985
fun returnsValueIfOk() {
8086
assertEquals(
@@ -94,6 +100,7 @@ class GetTest {
94100
}
95101

96102
class GetErrorOr {
103+
97104
@Test
98105
fun returnsDefaultValueIfOk() {
99106
assertEquals(
@@ -112,6 +119,7 @@ class GetTest {
112119
}
113120

114121
class GetOrElse {
122+
115123
@Test
116124
fun returnsValueIfOk() {
117125
assertEquals(
@@ -130,6 +138,7 @@ class GetTest {
130138
}
131139

132140
class GetErrorOrElse {
141+
133142
@Test
134143
fun returnsTransformedValueIfOk() {
135144
assertEquals(

kotlin-result/src/commonTest/kotlin/com/github/michaelbull/result/OrTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class OrTest {
2727
}
2828

2929
class OrElse {
30+
3031
@Test
3132
fun returnsValueIfOk() {
3233
assertEquals(

kotlin-result/src/commonTest/kotlin/com/github/michaelbull/result/UnwrapTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import kotlin.test.assertEquals
55
import kotlin.test.assertFailsWith
66

77
class UnwrapTest {
8+
89
class Unwrap {
10+
911
@Test
1012
fun returnsValueIfOk() {
1113
assertEquals(

0 commit comments

Comments
 (0)