Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Exclusion Hunter: ReturnValueIgnored and ReadReturnedValueIgnored (#5875
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jeremyk-91 authored Jan 31, 2022
1 parent 0dd3361 commit b41ae50
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void getRowsThrows() {
}

@Test
@SuppressWarnings("ReturnValueIgnored") // Assertion for test purposes
public void getRangeThrows() {
RangeRequest range = RangeRequest.builder().endRowExclusive(SECOND_ROW).build();
ClosableIterator<RowResult<Value>> resultIterator = getTestKvs().getRange(TEST_TABLE, range, Long.MAX_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public void canReadAcrossBlocksWithIncompleteFinalBlock() throws IOException {
}

@Test
@SuppressWarnings("ReadReturnValueIgnored") // Relates to part of system not under test in this test
public void readSingleByteWhenStreamExhaustedReturnsMinusOne() throws IOException {
dataStream.read(new byte[DATA_SIZE]);

Expand All @@ -167,6 +168,7 @@ public void readSingleByteWhenStreamExhaustedReturnsMinusOne() throws IOExceptio
}

@Test
@SuppressWarnings("ReadReturnValueIgnored") // Relates to part of system not under test in this test
public void readWhenStreamExhaustedReturnsMinusOne() throws IOException {
byte[] result = new byte[DATA_SIZE];
dataStream.read(result);
Expand Down Expand Up @@ -279,6 +281,7 @@ public int expectedBlockLength() {
}

@Test
@SuppressWarnings("ReadReturnValueIgnored") // Relates to part of system not under test in this test
public void canLoadMultipleBlocksAtOnceAndAlsoFewerBlocksAtEnd() throws IOException {
BlockGetter spiedGetter = Mockito.spy(singleByteConsumer);
BlockConsumingInputStream stream = BlockConsumingInputStream.create(spiedGetter, DATA_SIZE, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public MessageDigest newDigest() {
return createDigest(algorithm);
}

@SuppressWarnings("ReturnValueIgnored") // This method tests whether cloning is possible.
private static boolean supportsClone(MessageDigest prototype) {
try {
prototype.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void batchesConcurrentRequests() throws InterruptedException {
}

@Test
@SuppressWarnings("ReturnValueIgnored") // Test relating to properties of a Supplier
public void doesNotBatchSerialRequests() {
supplier.get();
supplier.get();
Expand Down Expand Up @@ -188,6 +189,7 @@ private static void sleep(int millis) {
}
}

@SuppressWarnings("ReturnValueIgnored") // Test relating to properties of a Supplier
private AsyncTasks getConcurrently(int count) {
return AsyncTasks.runInParallel(supplier::get, count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.mockito.Mockito.when;

import com.palantir.common.concurrent.PTExecutors;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
Expand Down Expand Up @@ -102,7 +101,7 @@ public void doesNotApplyFunctionIfGetIsInvokedAndSuppliedVersionConstant() {
}

@Test
public void appliesFunctionExactlyOncePerSuppliedValueChange() throws InterruptedException, ExecutionException {
public void appliesFunctionExactlyOncePerSuppliedValueChange() throws InterruptedException {
testSupplier = new CachedComposedSupplier<>(this::countingFunction, this::increasingNumber);
ExecutorService executorService = PTExecutors.newFixedThreadPool(16);
for (int i = 0; i < 100_000; i++) {
Expand All @@ -116,7 +115,8 @@ public void appliesFunctionExactlyOncePerSuppliedValueChange() throws Interrupte
}

@Test
public void recomputesIfSupplierHasNotUpdatedForTooLong() throws InterruptedException {
@SuppressWarnings("ReturnValueIgnored") // Test relating to properties of a Supplier
public void recomputesIfSupplierHasNotUpdatedForTooLong() {
AtomicLong clockCounter = new AtomicLong();
testSupplier = new CachedComposedSupplier<>(this::countingFunction, this::constantNumber, 5, clockCounter::get);
for (int i = 0; i < 25; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,7 @@ public void getSortedColumnsReturnsCellsSortedByColumn() {
}

@Test
@SuppressWarnings("ReturnValueIgnored") // Part of an assertion!
public void getSortedColumnsThrowsIfLockIsLost() {
List<Cell> cells = ImmutableList.of(Cell.create(ROW_FOO, COL_A));
putCellsInTable(cells, TABLE_SWEPT_THOROUGH);
Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ allprojects {
'FutureReturnValueIgnored',
'NarrowingCompoundAssignment',
'PublicConstructorForAbstractClass',
'ReadReturnValueIgnored',
'ReturnValueIgnored',
'Slf4jLogsafeArgs',
'StaticAssignmentInConstructor',
'StrictUnusedVariable'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public static <T> T runUninterruptably(
return result;
}

@SuppressWarnings("ReadReturnValueIgnored") // Read is from a byte array input stream; will read everything
public static void toStringSqlArgs(final StringBuilder sb, Object[] args) {
if (args instanceof Object[][]) {
// then we're doing a batch query
Expand Down

0 comments on commit b41ae50

Please sign in to comment.