Skip to content

Commit

Permalink
detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
Augusto César Dias committed Jan 26, 2024
1 parent fae9b02 commit 6b2caa8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ class LocalMonkey(monkeyType: MonkeyType, internalId: MonkeyId) : Monkey(monkeyT
}

override suspend fun createConversation(
name: String, monkeyList: List<Monkey>, protocol: ConversationOptions.Protocol, isDestroyable: Boolean
name: String,
monkeyList: List<Monkey>,
protocol: ConversationOptions.Protocol,
isDestroyable: Boolean
): MonkeyConversation {
val self = this
return this.monkeyState.readyThen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sealed class MonkeyType {
}
}

@Suppress("TooManyFunctions")
abstract class Monkey(val monkeyType: MonkeyType, val internalId: MonkeyId) {
companion object {
// this means there are users within the team not managed by IM
Expand Down Expand Up @@ -103,7 +104,10 @@ abstract class Monkey(val monkeyType: MonkeyType, val internalId: MonkeyId) {
abstract suspend fun pendingConnectionRequests(): List<ConversationDetails.Connection>

abstract suspend fun createConversation(
name: String, monkeyList: List<Monkey>, protocol: ConversationOptions.Protocol, isDestroyable: Boolean = true
name: String,
monkeyList: List<Monkey>,
protocol: ConversationOptions.Protocol,
isDestroyable: Boolean = true
): MonkeyConversation

abstract suspend fun leaveConversation(conversationId: ConversationId)
Expand All @@ -117,6 +121,7 @@ abstract class Monkey(val monkeyType: MonkeyType, val internalId: MonkeyId) {
abstract suspend fun sendDirectMessageTo(anotherMonkey: Monkey, message: String)

abstract suspend fun sendMessageTo(conversationId: ConversationId, message: String)
@Suppress("LongParameterList")
abstract suspend fun createPrefixedConversation(
name: String,
protocol: ConversationOptions.Protocol,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import io.ktor.http.ContentType
import io.ktor.http.Url
import io.ktor.http.contentType

@Suppress("TooManyFunctions")
class RemoteMonkey(private val httpClient: HttpClient, private val baseUrl: String, monkeyType: MonkeyType, internalId: MonkeyId) :
Monkey(monkeyType, internalId) {
private fun url(endpoint: String): Url {
Expand Down Expand Up @@ -129,7 +130,10 @@ class RemoteMonkey(private val httpClient: HttpClient, private val baseUrl: Stri
}

override suspend fun createConversation(
name: String, monkeyList: List<Monkey>, protocol: ConversationOptions.Protocol, isDestroyable: Boolean
name: String,
monkeyList: List<Monkey>,
protocol: ConversationOptions.Protocol,
isDestroyable: Boolean
): MonkeyConversation {
return post(
CREATE_CONVERSATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ object ConversationPool {
}

private suspend fun createDynamicConversation(
creator: Monkey, protocol: ConversationOptions.Protocol, monkeyList: List<Monkey>
creator: Monkey,
protocol: ConversationOptions.Protocol,
monkeyList: List<Monkey>
): ConversationDef {
val name = "By monkey ${creator.monkeyType.userId()} - $protocol - ${Random.nextUInt()}"
val conversation = creator.createConversation(name, monkeyList, protocol)
Expand All @@ -84,15 +86,20 @@ object ConversationPool {
}

suspend fun createDynamicConversation(
userCount: UserCount, protocol: ConversationOptions.Protocol, monkeyPool: MonkeyPool
userCount: UserCount,
protocol: ConversationOptions.Protocol,
monkeyPool: MonkeyPool
): ConversationDef {
val creator = monkeyPool.randomLoggedInMonkeys(UserCount.single())[0]
val members = creator.randomPeers(userCount, monkeyPool)
return this.createDynamicConversation(creator, protocol, members)
}

suspend fun createDynamicConversation(
team: String, userCount: UserCount, protocol: ConversationOptions.Protocol, monkeyPool: MonkeyPool
team: String,
userCount: UserCount,
protocol: ConversationOptions.Protocol,
monkeyPool: MonkeyPool
): ConversationDef {
val creator = monkeyPool.randomLoggedInMonkeysFromTeam(team, UserCount.single()).first()
val members = creator.randomPeers(userCount, monkeyPool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class MonkeyServer : CliktCommand() {
Monkey.internal(userData, MonkeyId.dummy())
}


override fun run() {
if (logOutputFile != null) {
CoreLogger.init(KaliumLogger.Config(logLevel, listOf(fileLogger)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.ktor.server.routing.get
import io.ktor.server.routing.post
import io.ktor.server.routing.routing

@Suppress("LongMethod")
fun Application.configureRoutes(monkey: Monkey, core: CoreLogic) {
install(ContentNegotiation) {
json()
Expand Down

0 comments on commit 6b2caa8

Please sign in to comment.