Skip to content

Commit

Permalink
Cleanup some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tokou committed Aug 25, 2024
1 parent 1c3b115 commit c483645
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 40 deletions.
4 changes: 2 additions & 2 deletions maestro-cli/src/main/java/maestro/cli/command/TestCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class TestCommand : Callable<Int> {
val chunkPlans = plan.flowsToRun
.withIndex()
.groupBy { it.index % shards }
.map { (shardIndex, files) ->
.map { (_, files) ->
ExecutionPlan(
files.map { it.value },
plan.sequence.also {
Expand Down Expand Up @@ -335,7 +335,7 @@ class TestCommand : Callable<Int> {
private fun printShardsMessage(passedTests: Int, totalTests: Int, shardResults: List<TestExecutionSummary>) {
val box = buildString {
val lines = listOf("Passed: $passedTests/$totalTests") +
shardResults.mapIndexed { index, result ->
shardResults.mapIndexed { _, result ->
"[ ${result.suites.first().deviceName} ] - ${result.passedCount ?: 0}/${result.totalTests ?: 0}"
}

Expand Down
8 changes: 4 additions & 4 deletions maestro-cli/src/main/java/maestro/cli/device/DeviceService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ object DeviceService {

fun listConnectedDevices(): List<Device.Connected> {
return listDevices()
.filterIsInstance(Device.Connected::class.java)
.filterIsInstance<Device.Connected>()
}

fun listAvailableForLaunchDevices(): List<Device.AvailableForLaunch> {
return listDevices()
.filterIsInstance(Device.AvailableForLaunch::class.java)
.filterIsInstance<Device.AvailableForLaunch>()
}

private fun listDevices(): List<Device> {
Expand Down Expand Up @@ -246,11 +246,11 @@ object DeviceService {
fun isDeviceAvailableToLaunch(deviceName: String, platform: Platform): Device.AvailableForLaunch? {
return if (platform == Platform.IOS) {
listIOSDevices()
.filterIsInstance(Device.AvailableForLaunch::class.java)
.filterIsInstance<Device.AvailableForLaunch>()
.find { it.description.contains(deviceName, ignoreCase = true) }
} else {
listAndroidDevices()
.filterIsInstance(Device.AvailableForLaunch::class.java)
.filterIsInstance<Device.AvailableForLaunch>()
.find { it.description.contains(deviceName, ignoreCase = true) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class HtmlTestSuiteReporter : TestSuiteReporter {
}
}
}
script(src = "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js", content = "")
script(src = "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js") {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package maestro.cli.report
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.databind.ObjectMapper
import maestro.Driver
import maestro.MaestroException
import maestro.TreeNode
import maestro.cli.runner.CommandStatus
Expand All @@ -25,7 +24,6 @@ import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import java.util.IdentityHashMap
import java.util.Properties
import kotlin.io.path.absolutePathString
import kotlin.io.path.exists

Expand Down Expand Up @@ -98,13 +96,6 @@ object TestDebugReporter {
}

private fun logSystemInfo() {
val appVersion = runCatching {
val props = Driver::class.java.classLoader.getResourceAsStream("version.properties").use {
Properties().apply { load(it) }
}
props["version"].toString()
}

val logger = LoggerFactory.getLogger("MAESTRO")
logger.info("---- System Info ----")
logger.info("Maestro Version: ${EnvUtils.CLI_VERSION ?: "Undefined"}")
Expand Down
1 change: 1 addition & 0 deletions maestro-client/src/main/java/maestro/drivers/WebDriver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class WebDriver(val isStudio: Boolean) : Driver {
swipe(direction, durationMs)
}

@Suppress("UNUSED_PARAMETER")
fun swipe(start: Point, end: Point) {
TODO("Not yet implemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import java.util.concurrent.TimeUnit
import kotlin.io.path.exists
import kotlin.io.path.isDirectory
import kotlin.io.path.readText
import kotlin.math.max

data class Auth(
val teamId: UUID,
Expand All @@ -38,8 +37,7 @@ data class GetEventsResponse(
val events: List<MockEvent>
)

class MockInteractor(
) {
class MockInteractor {
private val client = OkHttpClient.Builder()
.readTimeout(5, TimeUnit.MINUTES)
.writeTimeout(5, TimeUnit.MINUTES)
Expand Down Expand Up @@ -81,7 +79,6 @@ class MockInteractor(
error("Could not retrieve project id: ${e.message}")
}
}
return null
}

fun getMockEvents(): List<MockEvent> {
Expand All @@ -100,13 +97,11 @@ class MockInteractor(

response.use {
try {
val response = JSON.readValue(response.body?.bytes(), GetEventsResponse::class.java)
return response.events
return JSON.readValue(response.body?.bytes(), GetEventsResponse::class.java).events
} catch (e: Exception) {
error("Could not retrieve mock events: ${e.message}")
}
}
return emptyList()
}

companion object {
Expand All @@ -133,4 +128,4 @@ class MockInteractor(

fun main() {
MockInteractor().getMockEvents()
}
}
2 changes: 1 addition & 1 deletion maestro-ios/src/main/java/ios/simctl/SimctlIOSDevice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SimctlIOSDevice(
deviceId = deviceId,
bundleId = id,
launchArguments = iOSLaunchArguments,
sessionId = maestroSessionId?.toString() ?: null,
sessionId = maestroSessionId?.toString(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ data class MaestroConfig(
}

data class MaestroOnFlowComplete(val commands: List<MaestroCommand>) {
fun evaluateScripts(jsEngine: JsEngine): MaestroOnFlowComplete {
fun evaluateScripts(@Suppress("UNUSED_PARAMETER") jsEngine: JsEngine): MaestroOnFlowComplete {
return this
}
}

data class MaestroOnFlowStart(val commands: List<MaestroCommand>) {
fun evaluateScripts(jsEngine: JsEngine): MaestroOnFlowStart {
fun evaluateScripts(@Suppress("UNUSED_PARAMETER") jsEngine: JsEngine): MaestroOnFlowStart {
return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class WorkspaceConfig(
val executionOrder: ExecutionOrder? = null
) {

@Suppress("UNUSED_PARAMETER")
@JsonAnySetter
fun setOtherField(key: String, other: Any?) {
// Do nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal class MaestroCommandSerializationTest {
@Test
fun `serialize TapOnPointCommand`() {
// given
val command = MaestroCommand(
@Suppress("DEPRECATION") val command = MaestroCommand(
TapOnPointCommand(
x = 100,
y = 100,
Expand Down Expand Up @@ -218,7 +218,7 @@ internal class MaestroCommandSerializationTest {
@Test
fun `serialize AssertCommand`() {
// given
val command = MaestroCommand(
@Suppress("DEPRECATION") val command = MaestroCommand(
AssertCommand(
ElementSelector(textRegex = "[A-f0-9]"),
ElementSelector(textRegex = "\\s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ object DeviceService {
call.respond(response)
}
}
routing.static("/screenshot") {
staticRootFolder = SCREENSHOT_DIR.toFile()
files(".")
}
routing.staticFiles("/screenshot", SCREENSHOT_DIR.toFile())
}

private fun executeCommands(maestro: Maestro, commands: List<MaestroCommand>): Throwable? {
Expand Down Expand Up @@ -231,4 +228,4 @@ object DeviceService {
screenshotDir.createDirectories()
return screenshotDir
}
}
}
16 changes: 10 additions & 6 deletions maestro-studio/web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c483645

Please sign in to comment.