From e39d2e2be987d9ec51c9c4655d28a43fc1c8db43 Mon Sep 17 00:00:00 2001 From: James Rich Date: Tue, 17 Mar 2026 12:34:25 -0500 Subject: [PATCH] style(core): Fix detekt linting errors after code extraction --- .../core/network/radio/BleRadioInterface.kt | 2 + .../core/network/repository/NsdManager.kt | 2 + .../network/repository/ProbeTableProvider.kt | 2 + .../repository/SerialConnectionImpl.kt | 2 + .../meshtastic/core/service/MeshService.kt | 14 ----- .../service/MeshServiceOrchestratorTest.kt | 55 ++++++++++++++----- 6 files changed, 48 insertions(+), 29 deletions(-) diff --git a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt index 46b6aa349..af4b9f320 100644 --- a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/radio/BleRadioInterface.kt @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +@file:Suppress("TooManyFunctions", "TooGenericExceptionCaught") + package org.meshtastic.core.network.radio import android.annotation.SuppressLint diff --git a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt index ab3926510..ce272bf59 100644 --- a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/NsdManager.kt @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +@file:Suppress("SwallowedException") + package org.meshtastic.core.network.repository import android.annotation.SuppressLint diff --git a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt index 433d96de5..15558118e 100644 --- a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/ProbeTableProvider.kt @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +@file:Suppress("MagicNumber") + package org.meshtastic.core.network.repository import com.hoho.android.usbserial.driver.CdcAcmSerialDriver diff --git a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt index e2d787920..b2ccf6545 100644 --- a/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt +++ b/core/network/src/androidMain/kotlin/org/meshtastic/core/network/repository/SerialConnectionImpl.kt @@ -14,6 +14,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +@file:Suppress("MagicNumber") + package org.meshtastic.core.network.repository import android.hardware.usb.UsbManager diff --git a/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt index 675ed0413..c87abb1df 100644 --- a/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt +++ b/core/service/src/androidMain/kotlin/org/meshtastic/core/service/MeshService.kt @@ -27,12 +27,8 @@ import co.touchlab.kermit.Logger import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach import org.koin.android.ext.android.inject - import org.meshtastic.core.common.hasLocationPermission -import org.meshtastic.core.common.util.handledLaunch import org.meshtastic.core.common.util.toRemoteExceptions import org.meshtastic.core.model.DataPacket import org.meshtastic.core.model.DeviceVersion @@ -43,18 +39,12 @@ import org.meshtastic.core.model.Position import org.meshtastic.core.model.RadioNotConnectedException import org.meshtastic.core.repository.CommandSender import org.meshtastic.core.repository.MeshConnectionManager -import org.meshtastic.core.repository.MeshLocationManager -import org.meshtastic.core.repository.MeshMessageProcessor import org.meshtastic.core.repository.MeshRouter -import org.meshtastic.core.repository.MeshServiceNotifications import org.meshtastic.core.repository.NodeManager -import org.meshtastic.core.repository.PacketHandler import org.meshtastic.core.repository.RadioInterfaceService import org.meshtastic.core.repository.SERVICE_NOTIFY_ID import org.meshtastic.core.repository.ServiceBroadcasts import org.meshtastic.core.repository.ServiceRepository -import org.meshtastic.core.service.IMeshService - import org.meshtastic.proto.PortNum @Suppress("TooManyFunctions", "LargeClass") @@ -64,14 +54,10 @@ class MeshService : Service() { private val serviceRepository: ServiceRepository by inject() - private val packetHandler: PacketHandler by inject() - private val serviceBroadcasts: ServiceBroadcasts by inject() private val nodeManager: NodeManager by inject() - private val messageProcessor: MeshMessageProcessor by inject() - private val commandSender: CommandSender by inject() private val locationManager: MeshLocationManager by inject() diff --git a/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt b/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt index b8f174271..3afc27cd5 100644 --- a/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt +++ b/core/service/src/commonTest/kotlin/org/meshtastic/core/service/MeshServiceOrchestratorTest.kt @@ -1,13 +1,37 @@ +/* + * Copyright (c) 2026 Meshtastic LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package org.meshtastic.core.service import io.mockk.every import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.flow.MutableSharedFlow +import org.meshtastic.core.repository.CommandSender +import org.meshtastic.core.repository.MeshConnectionManager +import org.meshtastic.core.repository.MeshMessageProcessor +import org.meshtastic.core.repository.MeshRouter +import org.meshtastic.core.repository.MeshServiceNotifications +import org.meshtastic.core.repository.NodeManager +import org.meshtastic.core.repository.PacketHandler +import org.meshtastic.core.repository.RadioInterfaceService +import org.meshtastic.core.repository.ServiceRepository import kotlin.test.Test import kotlin.test.assertFalse import kotlin.test.assertTrue -import org.meshtastic.core.repository.* class MeshServiceOrchestratorTest { @@ -22,30 +46,31 @@ class MeshServiceOrchestratorTest { val connectionManager = mockk(relaxed = true) val router = mockk(relaxed = true) val serviceNotifications = mockk(relaxed = true) - + every { radioInterfaceService.receivedData } returns MutableSharedFlow() every { serviceRepository.serviceAction } returns MutableSharedFlow() - val orchestrator = MeshServiceOrchestrator( - radioInterfaceService, - serviceRepository, - packetHandler, - nodeManager, - messageProcessor, - commandSender, - connectionManager, - router, - serviceNotifications - ) + val orchestrator = + MeshServiceOrchestrator( + radioInterfaceService, + serviceRepository, + packetHandler, + nodeManager, + messageProcessor, + commandSender, + connectionManager, + router, + serviceNotifications, + ) assertFalse(orchestrator.isRunning) orchestrator.start() assertTrue(orchestrator.isRunning) - + verify { serviceNotifications.initChannels() } verify { packetHandler.start(any()) } verify { nodeManager.loadCachedNodeDB() } - + orchestrator.stop() assertFalse(orchestrator.isRunning) }