From ab4e3e8e80b00f98f2c207093208911dd4e50c7b Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Mon, 4 Sep 2023 15:03:53 -0400 Subject: [PATCH 1/4] Suppress warnings about unstable Gradle APIs We're intentionally using [an unstable Gradle Kotlin feature that allows direct `... = ...` assignment to `Property` instances](https://blog.gradle.org/simpler-kotlin-dsl-property-assignment). This feature may be considered unstable, but it's stable enough to have been [enabled by default since Gradle 8.2](https://docs.gradle.org/8.2.1/release-notes.html#simple-property-assignment-in-kotlin-dsl-enabled-by-default). --- build-logic/build.gradle.kts | 2 ++ build-logic/src/main/kotlin/com/ibm/wala/gradle/java.gradle.kts | 2 ++ .../src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts | 2 ++ cast/java/ecj/build.gradle.kts | 2 ++ cast/java/test/data/build.gradle.kts | 2 ++ cast/js/build.gradle.kts | 2 ++ cast/js/nodejs/build.gradle.kts | 2 ++ core/build.gradle.kts | 2 ++ 8 files changed, 16 insertions(+) diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index 809cb665f9..7e7b2dfdb1 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + import com.diffplug.spotless.LineEnding.PLATFORM_NATIVE plugins { diff --git a/build-logic/src/main/kotlin/com/ibm/wala/gradle/java.gradle.kts b/build-logic/src/main/kotlin/com/ibm/wala/gradle/java.gradle.kts index 7c17bf826b..c8ed0b35cd 100644 --- a/build-logic/src/main/kotlin/com/ibm/wala/gradle/java.gradle.kts +++ b/build-logic/src/main/kotlin/com/ibm/wala/gradle/java.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + package com.ibm.wala.gradle // Build configuration for subprojects that include Java source code. diff --git a/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts b/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts index 6fdf0f1369..c0e8dbc699 100644 --- a/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts +++ b/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + package com.ibm.wala.gradle plugins { diff --git a/cast/java/ecj/build.gradle.kts b/cast/java/ecj/build.gradle.kts index d35d85fc74..b0354cd822 100644 --- a/cast/java/ecj/build.gradle.kts +++ b/cast/java/ecj/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + plugins { application id("com.ibm.wala.gradle.eclipse-maven-central") diff --git a/cast/java/test/data/build.gradle.kts b/cast/java/test/data/build.gradle.kts index 26493918e3..4a4b6842e2 100644 --- a/cast/java/test/data/build.gradle.kts +++ b/cast/java/test/data/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + import com.ibm.wala.gradle.VerifiedDownload import java.net.URI import net.ltgt.gradle.errorprone.errorprone diff --git a/cast/js/build.gradle.kts b/cast/js/build.gradle.kts index 2db28133e9..f8940226ce 100644 --- a/cast/js/build.gradle.kts +++ b/cast/js/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + import com.ibm.wala.gradle.CreatePackageList import com.ibm.wala.gradle.VerifiedDownload import java.net.URI diff --git a/cast/js/nodejs/build.gradle.kts b/cast/js/nodejs/build.gradle.kts index 7cfaf2085a..91f9ad434d 100644 --- a/cast/js/nodejs/build.gradle.kts +++ b/cast/js/nodejs/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + import com.ibm.wala.gradle.VerifiedDownload import java.net.URI diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 62c6e7536b..f032777f5c 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("UnstableApiUsage") + import com.ibm.wala.gradle.CompileKawaScheme import com.ibm.wala.gradle.JavaCompileUsingEcj import com.ibm.wala.gradle.VerifiedDownload From 1f962e6dd781c3ec1cec1124f4926aa0caed9095 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Mon, 4 Sep 2023 14:46:47 -0400 Subject: [PATCH 2/4] Suppress warnings about safe `this` leaks Leaking `this` before the constructor has completed can be dangerous in general, specifically if any methods are called or not-yet-initialized fields are used. However, in the specific cases addressed here, the escaping `this` is merely recorded in fields of other objects for later use. Members of `this` instance are not actually used during construction, so these escapes are safe. --- .../src/main/kotlin/com/ibm/wala/gradle/VerifiedDownload.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-logic/src/main/kotlin/com/ibm/wala/gradle/VerifiedDownload.kt b/build-logic/src/main/kotlin/com/ibm/wala/gradle/VerifiedDownload.kt index 869f593c54..af1efb2919 100644 --- a/build-logic/src/main/kotlin/com/ibm/wala/gradle/VerifiedDownload.kt +++ b/build-logic/src/main/kotlin/com/ibm/wala/gradle/VerifiedDownload.kt @@ -38,11 +38,13 @@ abstract class VerifiedDownload : DefaultTask() { // plugin-provided extension for downloading a resource from some URL @Internal + @Suppress("LeakingThis") val downloadExtension: DownloadExtension = project.objects.newInstance(DownloadExtension::class.java, this) // plugin-provided extension for verifying that a file has the expected checksum @Internal + @Suppress("LeakingThis") val verifyExtension: VerifyExtension = project.objects.newInstance(VerifyExtension::class.java, this) From 4369ca29bcd4db3bebace51d875bcac0a6172e05 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Mon, 4 Sep 2023 14:45:09 -0400 Subject: [PATCH 3/4] Add explicit Kotlin types These values are returned from Java code without nullability information. Kotlin needs a little extra help to know whether those Java APIs can return `null` here or not. --- .../src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts b/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts index c0e8dbc699..0810ea0472 100644 --- a/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts +++ b/build-logic/src/main/kotlin/com/ibm/wala/gradle/publishing.gradle.kts @@ -123,9 +123,9 @@ val mavenPublication = } } -val repositories = publishing.repositories +val repositories: RepositoryHandler = publishing.repositories -val mavenRepository = +val mavenRepository: MavenArtifactRepository = repositories.maven { url = uri( From e8967ec615c24fcd3dd3c1595b602ba49ff00bf8 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Mon, 4 Sep 2023 14:39:18 -0400 Subject: [PATCH 4/4] Conform to Python naming conventions Python local variables generally use `snake_case` names. --- summarize-time-trials | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/summarize-time-trials b/summarize-time-trials index 0911963118..6171e83389 100755 --- a/summarize-time-trials +++ b/summarize-time-trials @@ -36,14 +36,14 @@ def main(): # print slowest individual tests, showing only those in the 95% percentile # or higher (slower) - rankedTimes = pandas.DataFrame(times) - rankedTimes['percentRank'] = times.rank(pct=True) - elapsedTimes = rankedTimes['elapsedTime'] - rankedTimes['fractionOfTotal'] = elapsedTimes / elapsedTimes.sum() - isSlow = rankedTimes['percentRank'] >= .95 - slowestTests = rankedTimes[isSlow][::-1] + ranked_times = pandas.DataFrame(times) + ranked_times['percentRank'] = times.rank(pct=True) + elapsed_times = ranked_times['elapsedTime'] + ranked_times['fractionOfTotal'] = elapsed_times / elapsed_times.sum() + is_slow = ranked_times['percentRank'] >= .95 + slowest_tests = ranked_times[is_slow][::-1] print('Slowest individual tests:') - print(slowestTests.to_string(formatters={'percentRank': '{:.1%}'.format})) + print(slowest_tests.to_string(formatters={'percentRank': '{:.1%}'.format})) if __name__ == '__main__':