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

Automatic code cleanup. #1040

Merged
merged 1 commit into from
Feb 6, 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 @@ -20,7 +20,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Range;
import com.google.common.truth.Truth8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -181,11 +180,11 @@ public void paramsFile() throws IOException {

@Test
public void assumeFilename() {
Truth8.assertThat(
assertThat(
CommandLineOptionsParser.parse(Arrays.asList("--assume-filename", "Foo.java"))
.assumeFilename())
.hasValue("Foo.java");
Truth8.assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename())
assertThat(CommandLineOptionsParser.parse(Arrays.asList("Foo.java")).assumeFilename())
.isEmpty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.common.truth.Truth8;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ServiceLoader;
Expand All @@ -33,7 +32,7 @@ public class GoogleJavaFormatToolProviderTest {
public void testUsageOutputAfterLoadingViaToolName() {
String name = "google-java-format";

Truth8.assertThat(
assertThat(
ServiceLoader.load(ToolProvider.class).stream()
.map(ServiceLoader.Provider::get)
.map(ToolProvider::name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.truth.Truth8;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
Expand All @@ -35,7 +34,7 @@ public class GoogleJavaFormatToolTest {
public void testUsageOutputAfterLoadingViaToolName() {
String name = "google-java-format";

Truth8.assertThat(
assertThat(
ServiceLoader.load(Tool.class).stream()
.map(ServiceLoader.Provider::get)
.map(Tool::name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.common.truth.Truth.assertThat;

import com.google.common.base.Splitter;
import com.google.common.truth.Truth8;
import com.google.googlejavaformat.java.TypeNameClassifier.JavaCaseFormat;
import java.util.Optional;
import org.junit.Test;
Expand Down Expand Up @@ -52,26 +51,25 @@ private static Optional<Integer> getPrefix(String qualifiedName) {

@Test
public void typePrefixLength() {
Truth8.assertThat(getPrefix("fieldName")).isEmpty();
Truth8.assertThat(getPrefix("CONST")).isEmpty();
Truth8.assertThat(getPrefix("ClassName")).hasValue(0);
Truth8.assertThat(getPrefix("com.ClassName")).hasValue(1);
Truth8.assertThat(getPrefix("ClassName.foo")).hasValue(1);
Truth8.assertThat(getPrefix("com.ClassName.foo")).hasValue(2);
Truth8.assertThat(getPrefix("ClassName.foo.bar")).hasValue(1);
Truth8.assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2);
Truth8.assertThat(getPrefix("ClassName.CONST")).hasValue(1);
Truth8.assertThat(getPrefix("ClassName.varName")).hasValue(1);
Truth8.assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2);
Truth8.assertThat(getPrefix("com.R.foo")).hasValue(2);
assertThat(getPrefix("fieldName")).isEmpty();
assertThat(getPrefix("CONST")).isEmpty();
assertThat(getPrefix("ClassName")).hasValue(0);
assertThat(getPrefix("com.ClassName")).hasValue(1);
assertThat(getPrefix("ClassName.foo")).hasValue(1);
assertThat(getPrefix("com.ClassName.foo")).hasValue(2);
assertThat(getPrefix("ClassName.foo.bar")).hasValue(1);
assertThat(getPrefix("com.ClassName.foo.bar")).hasValue(2);
assertThat(getPrefix("ClassName.CONST")).hasValue(1);
assertThat(getPrefix("ClassName.varName")).hasValue(1);
assertThat(getPrefix("ClassName.Inner.varName")).hasValue(2);
assertThat(getPrefix("com.R.foo")).hasValue(2);
}

@Test
public void ambiguousClass() {
Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder"))
.hasValue(7);
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder")).hasValue(7);
// A human would probably identify this as "class-shaped", but just looking
// at the case we have to assume it could be something like `field1.field2.CONST`.
Truth8.assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty();
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.newBuilder")).isEmpty();
}
}
Loading