Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: update kotlin to 1.5.10 and remove warnings #1965

Merged
merged 1 commit into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ object Versions {
const val APK_PARSER = "2.6.10"

// match to Tools -> Kotlin -> Configure Kotlin Plugin Updates -> Update Channel: Stable
const val KOTLIN = "1.4.32"
const val KOTLIN = "1.5.10"

// https://github.com/Kotlin/kotlinx.coroutines/releases
const val KOTLIN_COROUTINES = "1.4.3"
const val KOTLIN_COROUTINES = "1.5.0"

// https://github.com/remkop/picocli/releases
const val PICOCLI = "4.6.1"
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/kotlin/flank/common/Os.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package flank.common

private val osName = System.getProperty("os.name")?.toLowerCase() ?: ""
private val osName = System.getProperty("os.name")?.lowercase() ?: ""

val isMacOS: Boolean by lazy {
val isMacOS = osName.indexOf("mac") >= 0
Expand Down
2 changes: 0 additions & 2 deletions corellium/adapter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ plugins {
}

repositories {
jcenter()
mavenCentral()
maven(url = "https://kotlin.bintray.com/kotlinx")
}

tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = "1.8" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.coroutines.launch

val executeAndroidTestPlan = AndroidTestPlan.Execute { config ->
config.instances.map { (instanceId, commands: List<String>) ->
channelFlow {
channelFlow<String> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For curios developers, this caused build errors (missing explicit type)

println("Getting console $instanceId")
corellium.connectConsole(instanceId).apply {
clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private const val SCREEN = "720x1280:280"
fun invokeAndroidDevices(
projectName: String,
) = AndroidInstance.Invoke { (amount) ->
channelFlow {
channelFlow<String> {
val projectId = getProjectId(projectName)
val instances = getCreatedInstances(projectId, amount)
startNotRunningInstances(instances)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ suspend fun Corellium.getVPNConfig(
) {
val response: HttpResponse = withRetry {
client.get {
url("$urlBase/projects/$projectId/vpn-configs/$id.${type.name.toLowerCase()}")
url("$urlBase/projects/$projectId/vpn-configs/$id.${type.name.lowercase()}")
header("Authorization", token)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ private fun List<List<Shard.App>>.printShards() {

private fun List<List<Shard.App>>.verifyDurationEqual() {
map {
it.sumByDouble {
it.tests.sumByDouble {
it.cases.sumByDouble {
it.sumOf {
it.tests.sumOf {
it.cases.sumOf {
it.duration.toDouble()
}
}
Expand Down
2 changes: 1 addition & 1 deletion flank-scripts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.9.15"
version = "1.9.16"
group = "com.github.flank"

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ private fun GithubPullRequest.toReleaseNoteMessage() =
}

internal fun String.mapPrTitleWithType() = when {
startsWith("feat") -> "Features" to skipConventionalCommitPrefix().capitalize()
startsWith("fix") -> "Bug Fixes" to skipConventionalCommitPrefix().capitalize()
startsWith("docs") -> "Documentation" to skipConventionalCommitPrefix().capitalize()
startsWith("refactor") -> "Refactor" to skipConventionalCommitPrefix().capitalize()
startsWith("ci") -> "CI Changes" to skipConventionalCommitPrefix().capitalize()
startsWith("test") -> "Tests update" to skipConventionalCommitPrefix().capitalize()
startsWith("perf") -> "Performance upgrade" to skipConventionalCommitPrefix().capitalize()
startsWith("feat") -> "Features" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
startsWith("fix") -> "Bug Fixes" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
startsWith("docs") -> "Documentation" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
startsWith("refactor") -> "Refactor" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
startsWith("ci") -> "CI Changes" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
startsWith("test") -> "Tests update" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
startsWith("perf") -> "Performance upgrade" to skipConventionalCommitPrefix().replaceFirstChar { it.uppercase() }
else -> null // we do not accept other prefix to have update in release notes
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ enum class ITResult {

object ITResultSerializer : KSerializer<ITResult> {
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("ITResult", PrimitiveKind.STRING)
override fun deserialize(decoder: Decoder) = ITResult.valueOf(decoder.decodeString().toUpperCase())
override fun serialize(encoder: Encoder, value: ITResult) = encoder.encodeString(value.name.toLowerCase())
override fun deserialize(decoder: Decoder) = ITResult.valueOf(decoder.decodeString().uppercase())
override fun serialize(encoder: Encoder, value: ITResult) = encoder.encodeString(value.name.lowercase())
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class VersionParseTest(

sealed class Compare(private val lambda: (Int) -> Boolean) {
operator fun invoke(int: Int) = lambda(int)
fun name() = this::class.simpleName?.toUpperCase() ?: ""
fun name() = this::class.simpleName?.uppercase() ?: ""
override fun toString() = name()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class CustomShardingIT {
.map { it.testAxises }
.flatten()

assertThat(testsResults.sumBy { it.suiteOverview.failures }).isEqualTo(5)
assertThat(testsResults.sumBy { it.suiteOverview.total }).isEqualTo(41)
assertThat(testsResults.sumOf { it.suiteOverview.failures }).isEqualTo(5)
assertThat(testsResults.sumOf { it.suiteOverview.total }).isEqualTo(41)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class MultipleApksIT {
.map { it.testAxises }
.flatten()

assertThat(testsResults.sumBy { it.suiteOverview.failures }).isEqualTo(5)
assertThat(testsResults.sumBy { it.suiteOverview.total }).isEqualTo(41)
assertThat(testsResults.sumOf { it.suiteOverview.failures }).isEqualTo(5)
assertThat(testsResults.sumOf { it.suiteOverview.total }).isEqualTo(41)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MultipleDevicesIT {
.map { it.testAxises }
.flatten()

assertThat(testsResults.sumBy { it.suiteOverview.failures }).isEqualTo(15)
assertThat(testsResults.sumBy { it.suiteOverview.total }).isEqualTo(123)
assertThat(testsResults.sumOf { it.suiteOverview.failures }).isEqualTo(15)
assertThat(testsResults.sumOf { it.suiteOverview.total }).isEqualTo(123)
}
}
2 changes: 1 addition & 1 deletion integration_tests/src/test/kotlin/utils/OutputHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun TestSuites.assertTestResultContainsWebLinks() =
}

fun TestSuites.assertCountOfSkippedTests(expectedCount: Int) =
assertEquals(expectedCount, testSuites.sumBy { it.skipped })
assertEquals(expectedCount, testSuites.sumOf { it.skipped })

fun TestSuites.assertCountOfFailedTests(expectedCount: Int) =
assertEquals(expectedCount, testSuites.count { it.failures > 0 })
Expand Down
3 changes: 2 additions & 1 deletion test_runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ signing {

// http://www.eclemma.org/jacoco/
jacoco {
toolVersion = "0.8.6"
toolVersion = "0.8.7"
}

tasks.jacocoTestReport {
Expand Down Expand Up @@ -194,6 +194,7 @@ dependencies {
implementation(Dependencies.KTOR_GSON)

implementation(Dependencies.KOTLIN_COROUTINES_CORE)
implementation(Dependencies.KOTLIN_REFLECT)

implementation(Dependencies.LOGBACK)

Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ AndroidArgs
run-timeout: $runTimeout
legacy-junit-result: $useLegacyJUnitResult
ignore-failed-tests: $ignoreFailedTests
output-style: ${outputStyle.name.toLowerCase()}
output-style: ${outputStyle.name.lowercase()}
disable-results-upload: $disableResultsUpload
default-class-test-time: $defaultClassTestTime
disable-usage-statistics: $disableUsageStatistics
Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ object ArgsHelper {
return bucket
}

fun getDefaultProjectIdOrNull() = (if (useMock) "mock-project-id" else getUserProjectId())?.toLowerCase()
fun getDefaultProjectIdOrNull() = (if (useMock) "mock-project-id" else getUserProjectId())?.lowercase()

// Allow users control over project by checking using Google's logic first before falling back to JSON.
private fun getUserProjectId(): String? = fromUserProvidedCredentials()
Expand Down
4 changes: 2 additions & 2 deletions test_runner/src/main/kotlin/ftl/args/CreateCommonArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fun CommonConfig.createCommonArgs(
// gcloud
devices = gcloud::devices.require(),
resultsBucket = ArgsHelper.createGcsBucket(
projectId = flank::project.require().toLowerCase(),
projectId = flank::project.require().lowercase(),
bucket = gcloud::resultsBucket.require()
),
resultsDir = gcloud.resultsDir ?: uniqueObjectName(),
Expand All @@ -42,7 +42,7 @@ fun CommonConfig.createCommonArgs(
testTargetsAlwaysRun = flank::testTargetsAlwaysRun.require(),
runTimeout = flank::runTimeout.require(),
fullJUnitResult = flank::fullJUnitResult.require(),
project = flank::project.require().toLowerCase(),
project = flank::project.require().lowercase(),
outputStyle = outputStyle,
keepFilePath = flank::keepFilePath.require(),
ignoreFailedTests = flank::ignoreFailedTests.require(),
Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/IosArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ IosArgs
local-result-dir: $localResultDir
run-timeout: $runTimeout
ignore-failed-tests: $ignoreFailedTests
output-style: ${outputStyle.name.toLowerCase()}
output-style: ${outputStyle.name.lowercase()}
disable-results-upload: $disableResultsUpload
default-class-test-time: $defaultClassTestTime
disable-usage-statistics: $disableUsageStatistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ private fun getOverheadTime(
0.0 else
(overview.elapsedTime.millis() - testCases.sumTime()) / testCases.size

private fun List<TestCase>.sumTime(): Double = sumByDouble { it.elapsedTime.millis() }
private fun List<TestCase>.sumTime(): Double = sumOf { it.elapsedTime.millis() }
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enum class OutputReportType {
NONE,
JSON;

override fun toString() = super.toString().toLowerCase()
override fun toString() = super.toString().lowercase()

companion object {
fun fromName(name: String?) = if (name.equals(JSON.name, ignoreCase = true)) JSON else NONE
Expand Down
6 changes: 4 additions & 2 deletions test_runner/src/main/kotlin/ftl/run/status/OutputStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import ftl.run.exception.FlankConfigurationError

enum class OutputStyle { Verbose, Single, Multi, Compact }

fun String.asOutputStyle() = capitalize().let { capitalized ->
fun String.asOutputStyle() = replaceFirstChar { it.uppercase() }.let { capitalized ->
OutputStyle.values().find { style -> style.name == capitalized }
} ?: throw FlankConfigurationError("Cannot parse output-style: $this, it should be one of ${OutputStyle.values().map { it.name.toLowerCase() }}")
} ?: throw FlankConfigurationError(
"Cannot parse output-style: $this, it should be one of ${OutputStyle.values().map { it.name.lowercase() }}"
)
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/shard/ShardCount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private fun testTotalTime(
previousMethodDurations: Map<String, Double>,
defaultTestTime: Double,
defaultClassTestTime: Double
) = testsToRun.sumByDouble { flankTestMethod ->
) = testsToRun.sumOf { flankTestMethod ->
getTestMethodTime(
flankTestMethod,
previousMethodDurations,
Expand Down
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/util/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun uniqueObjectName(): String {
// A-Z: 65 - 90
repeat(4) {
val ascii = random.nextInt(26)
var letter = (ascii + 'a'.toInt()).toChar()
var letter = (ascii + 'a'.code).toChar()

if (ascii % 2 == 0) {
letter -= 32 // upcase
Expand Down
6 changes: 3 additions & 3 deletions test_runner/src/test/kotlin/ftl/shard/ShardTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ShardTest {
assertThat(it.testMethods).isNotEmpty()
}

assertThat(result.sumByDouble { it.time }).isEqualTo(16.5)
assertThat(result.sumOf { it.time }).isEqualTo(16.5)

val testNames = mutableListOf<String>()
result.forEach { shard ->
Expand All @@ -68,7 +68,7 @@ class ShardTest {
val result = createShardsByShardCount(testsToRun, JUnitTest.Result(null), mockArgs(2))

assertThat(result.size).isEqualTo(2)
assertThat(result.sumByDouble { it.time }).isEqualTo(3 * DEFAULT_TEST_TIME_SEC)
assertThat(result.sumOf { it.time }).isEqualTo(3 * DEFAULT_TEST_TIME_SEC)

val ordered = result.sortedBy { it.testMethods.size }
assertThat(ordered[0].testMethods.size).isEqualTo(1)
Expand All @@ -80,7 +80,7 @@ class ShardTest {
val testsToRun = listOfFlankTestMethod("a/a", "b/b", "c/c", "w", "y", "z")
val result = createShardsByShardCount(testsToRun, sample(), mockArgs(4))
assertThat(result.size).isEqualTo(4)
assertThat(result.sumByDouble { it.time }).isEqualTo(7.0 + 3 * DEFAULT_TEST_TIME_SEC)
assertThat(result.sumOf { it.time }).isEqualTo(7.0 + 3 * DEFAULT_TEST_TIME_SEC)

val ordered = result.sortedBy { it.testMethods.size }
// Expect a/a, b/b, c/c to be in one shard, and w, y, z to each be in their own shards.
Expand Down