Skip to content

Commit

Permalink
Enable extra javac warnings
Browse files Browse the repository at this point in the history
Issue: n/a
  • Loading branch information
mlopatkin committed May 15, 2024
1 parent 296c86a commit 26cf3c1
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private static Stream<Path> splitPathVariable(String pathVar) {
private int pos;

@Override
@SuppressWarnings("fallthrough")
protected @Nullable String computeNext() {
var result = new StringBuilder();
boolean inQuotes = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -42,12 +41,6 @@ public ListPropertyBuilder<T> defaultVal(List<T> value) {
return this;
}

@SafeVarargs
public final ListPropertyBuilder<T> defaultVal(T... value) {
this.defaultVal = Arrays.asList(value);
return this;
}

static <T> ListPropertyBuilder<T> newListPropertyBuilder(Class<T> type) {
return new ListPropertyBuilder<>(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ListTestUtils {
private ListTestUtils() {}

@SafeVarargs
@SuppressWarnings("varargs")
static <T> ArrayList<T> list(T... args) {
return new ArrayList<>(Arrays.asList(args));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ tasks.withType<JavaCompile>().configureEach {

// Configure javac warnings
options.compilerArgs.addAll(listOf(
"-Xlint:unchecked",
"-Xlint:rawtypes",
"-Xlint:deprecation",
"-Xlint:all",
"-Xlint:-serial,-processing",
"-Werror", // Treat warnings as errors
))
options.errorprone {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ public DeviceTempFile(IDevice device, String basePath) {
}

@Override
public void close() throws DeviceGoneException, InterruptedException {
DeviceUtils.executeShellCommand(device, String.format("rm %s", getPath()), NullOutputReceiver.getReceiver(), 1,
TimeUnit.SECONDS);
public void close() throws DeviceGoneException {
try {
DeviceUtils.executeShellCommand(device, String.format("rm %s", getPath()), NullOutputReceiver.getReceiver(),
1, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ interface OutputHandle extends AutoCloseable {
String getRedirectString(StdStream redirectFrom);

@Override
void close() throws IOException, DeviceGoneException, InterruptedException;
void close() throws IOException, DeviceGoneException;

}

Expand Down Expand Up @@ -164,9 +164,11 @@ public String getRedirectString(StdStream redirectFrom) {
}

@Override
public void close() throws DeviceGoneException, InterruptedException, IOException {
public void close() throws DeviceGoneException, IOException {
try (DeviceTempFile theTempFile = tempFile) {
theTempFile.copyContentsTo(stream);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void closingDeviceListNotifiesAboutDisconnectOfAllDevices() {
void provisionUpdatesDoNotTriggerNotificationsAfterClose() throws Exception {
adbFacade.connectDevice(createDevice("DeviceA"));
var provisioner = new FakeDeviceProvisioner();
var deviceList = createDeviceList(provisioner);
var deviceList = createDeviceListWith(provisioner);

var observer = mock(DeviceChangeObserver.class);
deviceList.asObservable().addObserver(observer);
Expand All @@ -245,7 +245,7 @@ void provisionUpdatesDoNotTriggerNotificationsAfterClose() throws Exception {
@Test
void devicesAddedInBackgroundAreNotVisibleInRunningListeners() throws Exception {
var testExecutor = new TestExecutor();
var deviceList = createDeviceList(testExecutor);
var deviceList = createDeviceListOn(testExecutor);

var observer = mock(DeviceChangeObserver.class);
doAnswer(device -> {
Expand All @@ -269,7 +269,7 @@ void devicesAddedInBackgroundAreNotVisibleInRunningListeners() throws Exception
@Test
void pendingNotificationsAreNotDeliveredAfterClosingInCallback() {
var testExecutor = new TestExecutor();
var deviceList = createDeviceList(testExecutor);
var deviceList = createDeviceListOn(testExecutor);

var observerA = mock(DeviceChangeObserver.class);

Expand Down Expand Up @@ -297,14 +297,14 @@ private IDevice createDevice(String serial) {
}

private AdbDeviceList createDeviceList() {
return createDeviceList(createProvisioner());
return createDeviceListWith(createProvisioner());
}

private AdbDeviceList createDeviceList(DeviceProvisioner provisioner) {
private AdbDeviceList createDeviceListWith(DeviceProvisioner provisioner) {
return DispatchingDeviceList.create(adbFacade, provisioner, testExecutor);
}

private AdbDeviceList createDeviceList(Executor executor) {
private AdbDeviceList createDeviceListOn(Executor executor) {
return DispatchingDeviceList.create(adbFacade, createProvisioner(), new TestSequentialExecutor(executor));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MultiplexParser<T extends BasePushParser> extends AbstractBasePushP
private final List<T> activeChildren;

@SafeVarargs
@SuppressWarnings("varargs")
public MultiplexParser(T... children) {
this(ImmutableList.copyOf(children));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
public class ListSearchModel<T> implements SearchDataModel<T, Integer> {
private final List<T> items;

@SafeVarargs
public ListSearchModel(T... items) {
this.items = ImmutableList.copyOf(items);
}

public ListSearchModel(List<T> items) {
this.items = ImmutableList.copyOf(items);
}
Expand Down

0 comments on commit 26cf3c1

Please sign in to comment.