Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable extra javac warnings #382

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -18,6 +18,7 @@ package name.mlopatkin.andlogview.building

import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.assign

/**
* Helper methods to access environment parameters: is build run by CI server? what revision is checked out?
Expand Down Expand Up @@ -45,8 +46,8 @@ abstract class BuildEnvironment(project: Project) {

val gitRevision = providers.of(GitRevisionValueSource::class.java) {
parameters {
repoRoot.set(projectDir)
fallback.set("n/a")
repoRoot = projectDir
fallback = "n/a"
}
}

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
Loading