diff --git a/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java b/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java index 0dbf40465fd1..6ac5fbebdc8c 100644 --- a/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java +++ b/core/trino-main/src/test/java/io/trino/operator/scalar/FunctionAssertions.java @@ -394,7 +394,8 @@ private void assertCachedInstanceHasBoundedRetainedSizeInTx(String projection, S newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), SOURCE_PAGE); // consume the iterator - Iterators.getOnlyElement(output); + @SuppressWarnings("unused") + Optional ignored = Iterators.getOnlyElement(output); long retainedSize = processor.getProjections().stream() .mapToLong(this::getRetainedSizeOfCachedInstance) diff --git a/core/trino-main/src/test/java/io/trino/operator/window/matcher/MatchAssert.java b/core/trino-main/src/test/java/io/trino/operator/window/matcher/MatchAssert.java index 0ba1ab26df84..8e499d359b86 100644 --- a/core/trino-main/src/test/java/io/trino/operator/window/matcher/MatchAssert.java +++ b/core/trino-main/src/test/java/io/trino/operator/window/matcher/MatchAssert.java @@ -66,7 +66,7 @@ public MatchAssert hasLabels(char[] expectedLabels) for (int i = 0; i < expectedLabels.length; i++) { mappedExpected[i] = labelMapping.get(new IrLabel(String.valueOf(expectedLabels[i]))); } - return satisfies(actual -> assertThat(actual.isMatched())) + return satisfies(actual -> assertThat(actual.isMatched()).isTrue()) .satisfies(actual -> assertThat(actual.getLabels().toArray()) .as("Matched labels") .isEqualTo(mappedExpected)); @@ -75,7 +75,7 @@ public MatchAssert hasLabels(char[] expectedLabels) @CanIgnoreReturnValue public MatchAssert hasCaptures(int[] expectedCaptures) { - return satisfies(actual -> assertThat(actual.isMatched())) + return satisfies(actual -> assertThat(actual.isMatched()).isTrue()) .satisfies(actual -> assertThat(actual.getExclusions().toArray()) .as("Captured exclusions") .isEqualTo(expectedCaptures)); @@ -84,7 +84,7 @@ public MatchAssert hasCaptures(int[] expectedCaptures) @CanIgnoreReturnValue public MatchAssert isNoMatch() { - return satisfies(actual -> assertThat(!actual.isMatched())); + return satisfies(actual -> assertThat(actual.isMatched()).isFalse()); } private static LabelEvaluator identityEvaluator(int[] input) diff --git a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java index eb742d1f6433..ba9b1e7ffd51 100644 --- a/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java +++ b/plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnector.java @@ -288,6 +288,7 @@ public void testGetTupleType() assertEquals(rowNumber, 2); } + @SuppressWarnings({"ResultOfMethodCallIgnored", "CheckReturnValue"}) // we only check if the values are valid, we don't need them otherwise private static void assertReadFields(RecordCursor cursor, List schema) { for (int columnIndex = 0; columnIndex < schema.size(); columnIndex++) { diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java index 460649a09917..5e025a7a202a 100644 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestBrokerQueries.java @@ -169,6 +169,6 @@ public void testBrokerResponseHasTooManyRows() LIMIT_FOR_BROKER_QUERIES); assertThatExceptionOfType(PinotException.class) .isThrownBy(() -> pageSource.getNextPage()) - .withFailMessage("Broker query returned '3' rows, maximum allowed is '2' rows. with query \"SELECT col_1, col_2, col_3 FROM test_table\""); + .withMessage("Broker query returned '3' rows, maximum allowed is '2' rows. with query \"SELECT col_1, col_2, col_3 FROM test_table\""); } } diff --git a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java index 31c173ff30c8..16a804b3db50 100755 --- a/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java +++ b/plugin/trino-pinot/src/test/java/io/trino/plugin/pinot/TestDynamicTable.java @@ -132,7 +132,7 @@ public void testDoubleWithScientificNotation() String tableName = "primitive_types_table"; String query = "SELECT string_col FROM " + tableName + " WHERE double_col = 3.5E5"; assertThatNullPointerException().isThrownBy(() -> buildFromPql(pinotMetadata, new SchemaTableName("default", query))) - .withFailMessage(""); + .withMessage(Runtime.version().feature() < 15 ? null : "Cannot invoke \"java.lang.Integer.intValue()\" because \"this.scale\" is null"); } @Test diff --git a/pom.xml b/pom.xml index 6a4a2a3de067..a5471a926cd0 100644 --- a/pom.xml +++ b/pom.xml @@ -1721,6 +1721,7 @@ -Xep:BadInstanceof:ERROR -Xep:BadShiftAmount:ERROR -Xep:BoxedPrimitiveConstructor:ERROR + -Xep:CheckReturnValue:ERROR -Xep:ClassCanBeStatic:ERROR -Xep:CompareToZero:ERROR -Xep:ComparingThisWithNull:ERROR diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestAlterTable.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestAlterTable.java index 0b3800877613..68246f238562 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestAlterTable.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/TestAlterTable.java @@ -73,7 +73,7 @@ public void renameColumn() assertQueryFailure(() -> query(format("ALTER TABLE %s RENAME COLUMN nationkey TO n_regionkeY", TABLE_NAME))) .hasMessageContaining("Column 'n_regionkey' already exists"); - assertThat(query(format("ALTER TABLE %s RENAME COLUMN nationkey TO n_nationkey", TABLE_NAME))); + query(format("ALTER TABLE %s RENAME COLUMN nationkey TO n_nationkey", TABLE_NAME)); } @Test(groups = {ALTER_TABLE, SMOKE}) diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveIgnoreAbsentPartitions.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveIgnoreAbsentPartitions.java index 6f81257ca4a1..bc0f640219cf 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveIgnoreAbsentPartitions.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/TestHiveIgnoreAbsentPartitions.java @@ -78,7 +78,7 @@ public void testShouldThrowErrorOnUnpartitionedTableMissingData() { String tableName = "unpartitioned_absent_table_data"; - assertThat(query("DROP TABLE IF EXISTS " + tableName)); + query("DROP TABLE IF EXISTS " + tableName); assertThat(query(format("CREATE TABLE %s AS SELECT * FROM (VALUES 1,2,3) t(dummy_col)", tableName))).containsOnly(row(3)); assertThat(query("SELECT count(*) FROM " + tableName)).containsOnly(row(3)); @@ -93,6 +93,6 @@ public void testShouldThrowErrorOnUnpartitionedTableMissingData() query("SET SESSION hive.ignore_absent_partitions = true"); assertQueryFailure(() -> query("SELECT count(*) FROM " + tableName)).hasMessageContaining("Partition location does not exist"); - assertThat(query("DROP TABLE " + tableName)); + query("DROP TABLE " + tableName); } }