Skip to content

Commit d86c5a0

Browse files
committed
Fix detekt warnings
1 parent f38a8a7 commit d86c5a0

File tree

11 files changed

+43
-17
lines changed

11 files changed

+43
-17
lines changed

Diff for: lambdarpc/config/detekt.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
complexity:
2+
# Functions boilerplate for multiple args
3+
LongParameterList:
4+
excludes: [ '**/functions/frontend/**' ]
5+
6+
exceptions:
7+
# Temporal, proper error handling should be implemented
8+
TooGenericExceptionCaught:
9+
excludes: [ '**/LibServiceImpl.kt', '**/AbstractConnectedFunction.kt' ]
10+
11+
formatting:
12+
# IDEA automatically folds imports by default
13+
NoWildcardImports:
14+
active: false
15+
# Does not agree with default formatting
16+
Indentation:
17+
excludes: ['**/exceptions/Exceptions.kt']
18+
19+
style:
20+
# IDEA automatically folds imports by default
21+
WildcardImport:
22+
active: false
23+
# Checking arguments list size in boilerplate implementations
24+
MagicNumber:
25+
excludes: ['**/BackendFunction.kt']
26+
27+
naming:
28+
# Does not always agree with IDEA default warnings
29+
FunctionNaming:
30+
active: false
31+
# Is not suitable for DSL
32+
MatchingDeclarationName:
33+
excludes: ['**/dsl/**']

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/dsl/LibService.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class ServiceNotFound internal constructor(id: ServiceId) : LambdaRpcException("
1919
* DSL class that creates libservice instance.
2020
*/
2121
class LibService(
22-
serviceId: ServiceId, endpoint: Endpoint,
22+
serviceId: ServiceId,
23+
endpoint: Endpoint,
2324
serviceRegistry: ServiceRegistry = MapServiceRegistry(),
2425
builder: LibServiceDSL.() -> Unit
2526
) {

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/dsl/ServiceDispatcher.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import io.lambdarpc.utils.ServiceId
1010
import io.lambdarpc.utils.associateRepeatable
1111
import io.lambdarpc.utils.sid
1212
import kotlinx.coroutines.CoroutineScope
13-
import java.util.*
13+
import java.util.UUID
1414
import kotlin.coroutines.AbstractCoroutineContextElement
1515
import kotlin.coroutines.CoroutineContext
1616

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/functions/FunctionCoder.kt

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ internal class FunctionCoder0<R>(
108108
rc
109109
)
110110
}
111-
112111
}
113112

114113
internal class FunctionCoder1<A, R>(

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/functions/frontend/AbstractConnectedFunction.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ internal abstract class AbstractConnectedFunction : KLoggable {
102102
outMessages.collectApply {
103103
when {
104104
hasFinalResponse() -> {
105-
logger.info { "${accessName}: final response received with id = ${finalResponse.executionId}" }
105+
logger.info {
106+
"$accessName: final response received with id = ${finalResponse.executionId}"
107+
}
106108
result = finalResponse
107109
cancel()
108110
}

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/service/LibServiceImpl.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,14 @@ internal class LibServiceImpl(
181181
val oldName = function.channelFunction.accessName
182182
val f = localFunctionRegistry[oldName.an] ?: error("Function $oldName does not exist kek")
183183
val name = functionRegistry.register(f)
184-
Entity(FunctionPrototype(object : BoundFunction {
184+
val boundFunction = object : BoundFunction {
185185
override val accessName: AccessName
186186
get() = name
187187
override val serviceId: ServiceId
188188
get() = this@LibServiceImpl.serviceId
189189
override val endpoint: Endpoint
190190
get() = this@LibServiceImpl.endpoint
191-
}))
191+
}
192+
Entity(FunctionPrototype(boundFunction))
192193
}
193194
}

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/transport/grpc/service/AbstractLibService.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@ import io.lambdarpc.transport.grpc.LibServiceGrpcKt
55
/**
66
* gRPC libservice abstract implementation.
77
*/
8-
internal abstract class AbstractLibService
9-
: LibServiceGrpcKt.LibServiceCoroutineImplBase()
8+
internal abstract class AbstractLibService : LibServiceGrpcKt.LibServiceCoroutineImplBase()

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/utils/Defs.kt

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ value class AccessName(val n: String) {
1010
val String.an: AccessName
1111
get() = AccessName(this)
1212

13-
1413
@JvmInline
1514
value class ExecutionId(private val id: UUID) {
1615
override fun toString(): String = id.toString()
@@ -25,7 +24,6 @@ val UUID.eid: ExecutionId
2524

2625
fun String.toEid() = ExecutionId(UUID.fromString(this))
2726

28-
2927
@JvmInline
3028
value class ServiceId(private val id: UUID) {
3129
override fun toString(): String = id.toString()

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/utils/Endpoint.kt

-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ value class Address(val a: String)
66
val String.addr: Address
77
get() = Address(this)
88

9-
109
@JvmInline
1110
value class Port(val p: Int)
1211

1312
val Int.port: Port
1413
get() = Port(this)
1514

16-
1715
data class Endpoint(val address: Address, val port: Port) {
1816
override fun toString(): String = "${address.a}:${port.p}"
1917
}

Diff for: lambdarpc/src/main/kotlin/io/lambdarpc/utils/_Kotlin.kt

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package io.lambdarpc.utils
22

33
import kotlinx.coroutines.flow.Flow
4-
import java.util.concurrent.atomic.AtomicReference
5-
import kotlin.reflect.KProperty
64

75
operator fun <K, V> Map<out K, List<V>>.plus(
86
map: Map<out K, List<V>>
@@ -40,8 +38,5 @@ inline fun <T, K, V> Iterable<T>.associateRepeatable(
4038

4139
fun unreachable(explanation: String): Nothing = error("Unreachable code reached: $explanation")
4240

43-
operator fun <V> AtomicReference<V>.getValue(_owner: Any?, property: KProperty<*>): V = get()
44-
operator fun <V> AtomicReference<V>.setValue(_owner: Any?, property: KProperty<*>, value: V) = set(value)
45-
4641
suspend fun <T> Flow<T>.collectApply(block: suspend T.() -> Unit) =
4742
collect { it.block() }

0 commit comments

Comments
 (0)