From 4c2a4d38ed58462e59339948a622858e619bd3e3 Mon Sep 17 00:00:00 2001 From: svc-excavator-bot Date: Mon, 8 Aug 2022 13:36:34 +0000 Subject: [PATCH 1/3] Excavator: Upgrades Baseline to the latest version --- build.gradle | 2 +- .../HumanReadableByteCount.java | 8 ++++---- .../HumanReadableByteCountTests.java | 15 ++++++++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 6ec19377..a751a724 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ buildscript { dependencies { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.5.0' - classpath 'com.palantir.baseline:gradle-baseline-java:4.42.0' + classpath 'com.palantir.baseline:gradle-baseline-java:4.153.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.1.0' classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.3' classpath 'com.palantir.javaformat:gradle-palantir-java-format:1.1.0' diff --git a/human-readable-types/src/main/java/com/palantir/humanreadabletypes/HumanReadableByteCount.java b/human-readable-types/src/main/java/com/palantir/humanreadabletypes/HumanReadableByteCount.java index 415a084a..c593268b 100644 --- a/human-readable-types/src/main/java/com/palantir/humanreadabletypes/HumanReadableByteCount.java +++ b/human-readable-types/src/main/java/com/palantir/humanreadabletypes/HumanReadableByteCount.java @@ -302,10 +302,10 @@ public String toString() { public enum ByteUnit { BYTE(1, "bytes"), KiB(1024L, "kibibytes"), - MiB((long) Math.pow(1024L, 2L), "mebibytes"), - GiB((long) Math.pow(1024L, 3L), "gibibytes"), - TiB((long) Math.pow(1024L, 4L), "tebibytes"), - PiB((long) Math.pow(1024L, 5L), "pebibytes"); + MiB((long) Math.pow((double) 1024L, (double) 2L), "mebibytes"), + GiB((long) Math.pow((double) 1024L, (double) 3L), "gibibytes"), + TiB((long) Math.pow((double) 1024L, (double) 4L), "tebibytes"), + PiB((long) Math.pow((double) 1024L, (double) 5L), "pebibytes"); private final long multiplier; private final String suffix; diff --git a/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java b/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java index d8d100fd..8d5c2d2a 100644 --- a/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java +++ b/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java @@ -44,27 +44,32 @@ public void testParseKibiBytes() { @Test public void testParseMibiBytes() { - assertStringsEqualToBytes((long) Math.pow(1024L, 2L) * 10L, "10m", "10mb", "10 mibibyte", "10 mibibytes"); + assertStringsEqualToBytes( + (long) Math.pow((double) 1024L, (double) 2L) * 10L, "10m", "10mb", "10 mibibyte", "10 mibibytes"); } @Test public void testParseMebiBytes() { - assertStringsEqualToBytes((long) Math.pow(1024L, 2L) * 10L, "10m", "10mb", "10 mebibyte", "10 mebibytes"); + assertStringsEqualToBytes( + (long) Math.pow((double) 1024L, (double) 2L) * 10L, "10m", "10mb", "10 mebibyte", "10 mebibytes"); } @Test public void testParseGibiBytes() { - assertStringsEqualToBytes((long) Math.pow(1024L, 3L) * 10L, "10g", "10gb", "10 gibibyte", "10 gibibytes"); + assertStringsEqualToBytes( + (long) Math.pow((double) 1024L, (double) 3L) * 10L, "10g", "10gb", "10 gibibyte", "10 gibibytes"); } @Test public void testParseTebiBytes() { - assertStringsEqualToBytes((long) Math.pow(1024L, 4L) * 10L, "10t", "10tb", "10 tebibyte", "10 tebibytes"); + assertStringsEqualToBytes( + (long) Math.pow((double) 1024L, (double) 4L) * 10L, "10t", "10tb", "10 tebibyte", "10 tebibytes"); } @Test public void testParsePebiBytes() { - assertStringsEqualToBytes((long) Math.pow(1024L, 5L) * 10L, "10p", "10pb", "10 pebibyte", "10 pebibytes"); + assertStringsEqualToBytes( + (long) Math.pow((double) 1024L, (double) 5L) * 10L, "10p", "10pb", "10 pebibyte", "10 pebibytes"); } @Test From 9ece1d9e02ec335cc7281eecf40359279126783b Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 22 Sep 2022 12:14:40 -0400 Subject: [PATCH 2/3] Address FloatCast warnings --- .../HumanReadableByteCountTests.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java b/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java index 8d5c2d2a..d98b16e4 100644 --- a/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java +++ b/human-readable-types/src/test/java/com/palantir/humanreadabletypes/HumanReadableByteCountTests.java @@ -44,32 +44,27 @@ public void testParseKibiBytes() { @Test public void testParseMibiBytes() { - assertStringsEqualToBytes( - (long) Math.pow((double) 1024L, (double) 2L) * 10L, "10m", "10mb", "10 mibibyte", "10 mibibytes"); + assertStringsEqualToBytes((long) (Math.pow(1024.0, 2.0) * 10.0), "10m", "10mb", "10 mibibyte", "10 mibibytes"); } @Test public void testParseMebiBytes() { - assertStringsEqualToBytes( - (long) Math.pow((double) 1024L, (double) 2L) * 10L, "10m", "10mb", "10 mebibyte", "10 mebibytes"); + assertStringsEqualToBytes((long) (Math.pow(1024.0, 2.0) * 10.0), "10m", "10mb", "10 mebibyte", "10 mebibytes"); } @Test public void testParseGibiBytes() { - assertStringsEqualToBytes( - (long) Math.pow((double) 1024L, (double) 3L) * 10L, "10g", "10gb", "10 gibibyte", "10 gibibytes"); + assertStringsEqualToBytes((long) (Math.pow(1024.0, 3.0) * 10.0), "10g", "10gb", "10 gibibyte", "10 gibibytes"); } @Test public void testParseTebiBytes() { - assertStringsEqualToBytes( - (long) Math.pow((double) 1024L, (double) 4L) * 10L, "10t", "10tb", "10 tebibyte", "10 tebibytes"); + assertStringsEqualToBytes((long) (Math.pow(1024.0, 4.0) * 10.0), "10t", "10tb", "10 tebibyte", "10 tebibytes"); } @Test public void testParsePebiBytes() { - assertStringsEqualToBytes( - (long) Math.pow((double) 1024L, (double) 5L) * 10L, "10p", "10pb", "10 pebibyte", "10 pebibytes"); + assertStringsEqualToBytes((long) (Math.pow(1024.0, 5.0) * 10.0), "10p", "10pb", "10 pebibyte", "10 pebibytes"); } @Test From 820217774f7e5b1c5e97125e3d1eb2fd6b5bbdeb Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Thu, 22 Sep 2022 12:17:49 -0400 Subject: [PATCH 3/3] gradle-baseline 4.175.0 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a751a724..c30f04b1 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ buildscript { dependencies { classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.5.0' - classpath 'com.palantir.baseline:gradle-baseline-java:4.153.0' + classpath 'com.palantir.baseline:gradle-baseline-java:4.175.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.1.0' classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.3' classpath 'com.palantir.javaformat:gradle-palantir-java-format:1.1.0'