1
0
mirror of https://github.com/google/nomulus synced 2026-05-13 11:21:46 +00:00

Add Errorprone plugin for removing FQCNs (#3021)

These annoy me and AI loves to add them. Let's automatically remove them.
This commit is contained in:
gbrodman
2026-04-23 16:17:19 -04:00
committed by GitHub
parent 925482ea58
commit 903414c76b
19 changed files with 67 additions and 67 deletions

View File

@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.util.concurrent.Uninterruptibles;
import jakarta.inject.Inject;
import java.io.Serializable;
import java.time.Duration;
import javax.annotation.concurrent.ThreadSafe;
import org.joda.time.ReadableDuration;
@@ -40,6 +41,6 @@ public final class SystemSleeper implements Sleeper, Serializable {
@Override
public void sleepUninterruptibly(ReadableDuration duration) {
checkArgument(duration.getMillis() >= 0);
Uninterruptibles.sleepUninterruptibly(java.time.Duration.ofMillis(duration.getMillis()));
Uninterruptibles.sleepUninterruptibly(Duration.ofMillis(duration.getMillis()));
}
}

View File

@@ -89,7 +89,7 @@ public class BillingCancellation extends BillingBase {
* the supplied targetId and deriving other metadata (clientId, billing time, and the cancellation
* reason) from the grace period.
*/
public static google.registry.model.billing.BillingCancellation forGracePeriod(
public static BillingCancellation forGracePeriod(
GracePeriod gracePeriod,
DateTime eventTime,
HistoryEntryId domainHistoryId,
@@ -116,12 +116,12 @@ public class BillingCancellation extends BillingBase {
}
@Override
public VKey<google.registry.model.billing.BillingCancellation> createVKey() {
public VKey<BillingCancellation> createVKey() {
return createVKey(getId());
}
public static VKey<google.registry.model.billing.BillingCancellation> createVKey(long id) {
return VKey.create(google.registry.model.billing.BillingCancellation.class, id);
public static VKey<BillingCancellation> createVKey(long id) {
return VKey.create(BillingCancellation.class, id);
}
@Override
@@ -129,15 +129,12 @@ public class BillingCancellation extends BillingBase {
return new Builder(clone(this));
}
/**
* A builder for {@link google.registry.model.billing.BillingCancellation} since it is immutable.
*/
public static class Builder
extends BillingBase.Builder<google.registry.model.billing.BillingCancellation, Builder> {
/** A builder for {@link BillingCancellation} since it is immutable. */
public static class Builder extends BillingBase.Builder<BillingCancellation, Builder> {
public Builder() {}
private Builder(google.registry.model.billing.BillingCancellation instance) {
private Builder(BillingCancellation instance) {
super(instance);
}
@@ -157,8 +154,8 @@ public class BillingCancellation extends BillingBase {
}
@Override
public google.registry.model.billing.BillingCancellation build() {
google.registry.model.billing.BillingCancellation instance = getInstance();
public BillingCancellation build() {
BillingCancellation instance = getInstance();
checkNotNull(instance.billingTime, "Must set billing time");
checkNotNull(instance.reason, "Must set reason");
checkState(

View File

@@ -151,12 +151,12 @@ public class BillingEvent extends BillingBase {
}
@Override
public VKey<google.registry.model.billing.BillingEvent> createVKey() {
public VKey<BillingEvent> createVKey() {
return createVKey(getId());
}
public static VKey<google.registry.model.billing.BillingEvent> createVKey(long id) {
return VKey.create(google.registry.model.billing.BillingEvent.class, id);
public static VKey<BillingEvent> createVKey(long id) {
return VKey.create(BillingEvent.class, id);
}
@Override
@@ -164,13 +164,12 @@ public class BillingEvent extends BillingBase {
return new Builder(clone(this));
}
/** A builder for {@link google.registry.model.billing.BillingEvent} since it is immutable. */
public static class Builder
extends BillingBase.Builder<google.registry.model.billing.BillingEvent, Builder> {
/** A builder for {@link BillingEvent} since it is immutable. */
public static class Builder extends BillingBase.Builder<BillingEvent, Builder> {
public Builder() {}
private Builder(google.registry.model.billing.BillingEvent instance) {
private Builder(BillingEvent instance) {
super(instance);
}
@@ -229,8 +228,8 @@ public class BillingEvent extends BillingBase {
}
@Override
public google.registry.model.billing.BillingEvent build() {
google.registry.model.billing.BillingEvent instance = getInstance();
public BillingEvent build() {
BillingEvent instance = getInstance();
checkNotNull(instance.billingTime);
checkNotNull(instance.cost);
checkState(!instance.cost.isNegative(), "Costs should be non-negative.");

View File

@@ -152,12 +152,12 @@ public class BillingRecurrence extends BillingBase {
}
@Override
public VKey<google.registry.model.billing.BillingRecurrence> createVKey() {
public VKey<BillingRecurrence> createVKey() {
return createVKey(getId());
}
public static VKey<google.registry.model.billing.BillingRecurrence> createVKey(Long id) {
return VKey.create(google.registry.model.billing.BillingRecurrence.class, id);
public static VKey<BillingRecurrence> createVKey(Long id) {
return VKey.create(BillingRecurrence.class, id);
}
@Override
@@ -165,15 +165,12 @@ public class BillingRecurrence extends BillingBase {
return new Builder(clone(this));
}
/**
* A builder for {@link google.registry.model.billing.BillingRecurrence} since it is immutable.
*/
public static class Builder
extends BillingBase.Builder<google.registry.model.billing.BillingRecurrence, Builder> {
/** A builder for {@link BillingRecurrence} since it is immutable. */
public static class Builder extends BillingBase.Builder<BillingRecurrence, Builder> {
public Builder() {}
private Builder(google.registry.model.billing.BillingRecurrence instance) {
private Builder(BillingRecurrence instance) {
super(instance);
}
@@ -216,8 +213,8 @@ public class BillingRecurrence extends BillingBase {
}
@Override
public google.registry.model.billing.BillingRecurrence build() {
google.registry.model.billing.BillingRecurrence instance = getInstance();
public BillingRecurrence build() {
BillingRecurrence instance = getInstance();
checkNotNull(instance.eventTime);
checkNotNull(instance.reason);
// Don't require recurrenceLastExpansion to be individually set on every new Recurrence.

View File

@@ -132,10 +132,8 @@ public class TimeOfYear extends ImmutableObject implements UnsafeSerializable {
Range<Instant> normalizedRange = range.intersection(Range.closed(START_INSTANT, END_INSTANT));
Range<Integer> yearRange =
Range.closed(
ZonedDateTime.ofInstant(normalizedRange.lowerEndpoint(), java.time.ZoneOffset.UTC)
.getYear(),
ZonedDateTime.ofInstant(normalizedRange.upperEndpoint(), java.time.ZoneOffset.UTC)
.getYear());
ZonedDateTime.ofInstant(normalizedRange.lowerEndpoint(), ZoneOffset.UTC).getYear(),
ZonedDateTime.ofInstant(normalizedRange.upperEndpoint(), ZoneOffset.UTC).getYear());
return ContiguousSet.create(yearRange, integers()).stream()
.map(this::toInstantWithYear)
.filter(normalizedRange)
@@ -170,7 +168,7 @@ public class TimeOfYear extends ImmutableObject implements UnsafeSerializable {
/** Get the first {@link Instant} with this month/day/millis that is at or after the start. */
public Instant getNextInstanceAtOrAfterInstant(Instant start) {
Instant withSameYear =
toInstantWithYear(ZonedDateTime.ofInstant(start, java.time.ZoneOffset.UTC).getYear());
toInstantWithYear(ZonedDateTime.ofInstant(start, ZoneOffset.UTC).getYear());
return isAtOrAfter(withSameYear, start) ? withSameYear : plusYears(withSameYear, 1);
}
@@ -188,7 +186,7 @@ public class TimeOfYear extends ImmutableObject implements UnsafeSerializable {
/** Get the first {@link Instant} with this month/day/millis that is at or before the end. */
public Instant getLastInstanceBeforeOrAtInstant(Instant end) {
Instant withSameYear =
toInstantWithYear(ZonedDateTime.ofInstant(end, java.time.ZoneOffset.UTC).getYear());
toInstantWithYear(ZonedDateTime.ofInstant(end, ZoneOffset.UTC).getYear());
return isBeforeOrAt(withSameYear, end) ? withSameYear : minusYears(withSameYear, 1);
}

View File

@@ -32,6 +32,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
import java.time.Instant;
import java.util.Optional;
@@ -44,7 +45,7 @@ import org.joda.time.DateTime;
* PackagePromotion in Cloud SQL.
*/
@Entity(name = "PackagePromotion")
@Table(indexes = {@jakarta.persistence.Index(columnList = "token")})
@Table(indexes = {@Index(columnList = "token")})
public class BulkPricingPackage extends ImmutableObject implements Buildable {
/** An autogenerated identifier for the bulk pricing promotion. */

View File

@@ -38,6 +38,7 @@ import google.registry.model.tld.label.DomainLabelMetrics.MetricsReservedListMat
import google.registry.persistence.EntityCallbacksListener.RecursivePostPersist;
import google.registry.persistence.EntityCallbacksListener.RecursivePreRemove;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Index;
import jakarta.persistence.Table;
@@ -56,7 +57,7 @@ import javax.annotation.Nullable;
* succeeds, we will end up with having two exact same reserved lists that differ only by
* revisionId. This is fine though, because we only use the list with the highest revisionId.
*/
@jakarta.persistence.Entity
@Entity
@Table(indexes = {@Index(columnList = "name", name = "reservedlist_name_idx")})
public final class ReservedList
extends BaseDomainLabelList<ReservationType, ReservedList.ReservedListEntry> {
@@ -103,7 +104,7 @@ public final class ReservedList
* A reserved list entry entity, persisted to the database, that represents a single label and its
* reservation type.
*/
@jakarta.persistence.Entity(name = "ReservedEntry")
@Entity(name = "ReservedEntry")
public static class ReservedListEntry extends DomainLabelEntry<ReservationType, ReservedListEntry>
implements Buildable, Serializable {

View File

@@ -19,12 +19,13 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import google.registry.model.common.CrossTldSingleton;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import java.time.Instant;
import java.util.Optional;
import javax.annotation.concurrent.Immutable;
/** Singleton for ICANN's TMCH CA certificate revocation list (CRL). */
@jakarta.persistence.Entity
@Entity
@Immutable
public final class TmchCrl extends CrossTldSingleton {

View File

@@ -16,6 +16,7 @@ package google.registry.privileges.secretmanager;
import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Splitter;
import java.util.List;
/**
@@ -38,7 +39,7 @@ public record SqlCredential(String login, String password) {
}
public static SqlCredential fromFormattedString(String sqlCredential) {
List<String> items = com.google.common.base.Splitter.on(SEPARATOR).splitToList(sqlCredential);
List<String> items = Splitter.on(SEPARATOR).splitToList(sqlCredential);
checkState(items.size() == 2, "Invalid SqlCredential string.");
return create(items.get(0), items.get(1));
}

View File

@@ -40,6 +40,7 @@ import google.registry.request.HttpException.UnprocessableEntityException;
import google.registry.request.Parameter;
import google.registry.request.auth.Auth;
import jakarta.inject.Inject;
import jakarta.persistence.Query;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
@@ -267,7 +268,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
replicaTm()
.transact(
() -> {
jakarta.persistence.Query query =
Query query =
replicaTm()
.getEntityManager()
.createNativeQuery(queryBuilder.toString(), Host.class)

View File

@@ -51,6 +51,7 @@ import java.util.Map;
import org.hibernate.CacheMode;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.query.SelectionQuery;
import org.joda.time.Duration;
/**
@@ -163,7 +164,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA
tm().query("FROM Domain WHERE tld = :tld AND deletionTime > :exportTime", Domain.class)
.setParameter("tld", tld)
.setParameter("exportTime", exportTime)
.unwrap(org.hibernate.query.SelectionQuery.class)
.unwrap(SelectionQuery.class)
.setCacheMode(CacheMode.IGNORE)
.scroll(ScrollMode.FORWARD_ONLY);
for (int i = 1; scrollableResults.next(); i = (i + 1) % BATCH_SIZE) {

View File

@@ -135,7 +135,7 @@ public class ResaveAllEppResourcesPipelineTest {
persistDomainWithDependentResources(
"domain", "tld", toDateTime(now), toDateTime(now), toDateTime(plusYears(now, 1)));
assertThat(loadAllOf(GracePeriod.class)).hasSize(1);
fakeClock.advanceBy(org.joda.time.Duration.standardDays(500));
fakeClock.advanceBy(Duration.standardDays(500));
runPipeline();
assertThat(loadAllOf(GracePeriod.class)).isEmpty();
}

View File

@@ -46,6 +46,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import google.registry.flows.EppException;
import google.registry.flows.EppException.UnimplementedCommandException;
import google.registry.flows.EppException.UnimplementedExtensionException;
import google.registry.flows.FlowUtils.NotLoggedInException;
import google.registry.flows.FlowUtils.UnknownCurrencyEppException;
@@ -686,8 +687,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
// This exception is referred to by its fully qualified path (rather than being imported) so
// that it is not included in the list of exceptions thrown by DomainRestoreRequestFlow, as this
// test EPP won't trigger the request flow at all.
EppException thrown = assertThrows(
google.registry.flows.EppException.UnimplementedCommandException.class, this::runFlow);
EppException thrown = assertThrows(UnimplementedCommandException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("domain restore reports are not supported");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}

View File

@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.monitoring.metrics.MetricRegistry;
import com.google.monitoring.metrics.MetricRegistryImpl;
import com.google.monitoring.metrics.VirtualMetric;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
import org.junit.jupiter.api.BeforeEach;
@@ -57,7 +58,7 @@ class JvmMetricsTests {
assertThat(registry.getRegisteredMetrics()).hasSize(3);
for (var metric : registry.getRegisteredMetrics()) {
assertThat(metric).isInstanceOf(com.google.monitoring.metrics.VirtualMetric.class);
assertThat(metric).isInstanceOf(VirtualMetric.class);
}
}

View File

@@ -36,6 +36,7 @@ import google.registry.testing.FakeClock;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.IntStream;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -161,7 +162,7 @@ public class MosApiMetricsTest {
@Test
void testRecordStates_partitionsTimeSeries_atLimit() throws IOException {
ImmutableList<TldServiceState> largeBatch =
java.util.stream.IntStream.range(0, 70)
IntStream.range(0, 70)
.mapToObj(i -> createTldState("tld-" + i, "UP", "UP"))
.collect(ImmutableList.toImmutableList());
mosApiMetrics.recordStates(largeBatch);

View File

@@ -41,33 +41,32 @@ public class DatabaseExceptionTest {
@Test
void getSqlError_sqlExceptionNoDetails() {
assertThat(getSqlError(new java.sql.SQLException())).isEmpty();
assertThat(getSqlError(new SQLException())).isEmpty();
}
@Test
void getSqlError_sqlExceptionWithSqlState() {
assertThat(getSqlError(new java.sql.SQLException("msg", "state")))
assertThat(getSqlError(new SQLException("msg", "state")))
.contains("\tSQL Error: 0, SQLState: state, message: msg.");
}
@Test
void getSqlError_sqlExceptionWithAllDetails() {
assertThat(getSqlError(new java.sql.SQLException("msg", "state", 1)))
assertThat(getSqlError(new SQLException("msg", "state", 1)))
.contains("\tSQL Error: 1, SQLState: state, message: msg.");
}
@Test
void getSqlError_chainedSqlExceptionWithAllDetails() {
SQLException sqlException = new java.sql.SQLException("msg", "state", 1);
SQLException sqlException = new SQLException("msg", "state", 1);
assertThat(getSqlError(new Exception("not-captured", sqlException)))
.contains("\tSQL Error: 1, SQLState: state, message: msg.");
}
@Test
void getSqlError_multipleChainedSqlExceptionWithAllDetails() {
SQLException lower = new java.sql.SQLException("lower", "lower-state", 1);
SQLException higher =
new java.sql.SQLException("higher", "higher-state", 2, new Exception(lower));
SQLException lower = new SQLException("lower", "lower-state", 1);
SQLException higher = new SQLException("higher", "higher-state", 2, new Exception(lower));
assertThat(getSqlError(new Exception(higher)))
.contains(
"\tSQL Error: 2, SQLState: higher-state, message: higher.\n"

View File

@@ -382,8 +382,8 @@ class AuthenticatedRegistrarAccessorTest {
@Test
void testConsoleUser_admin() {
google.registry.model.console.User consoleUser =
new google.registry.model.console.User.Builder()
User consoleUser =
new User.Builder()
.setEmailAddress("email@email.com")
.setUserRoles(
new UserRoles.Builder().setIsAdmin(true).setGlobalRole(GlobalRole.FTE).build())
@@ -408,8 +408,8 @@ class AuthenticatedRegistrarAccessorTest {
void testConsoleUser_globalRole() {
// Users with global roles shouldn't necessarily have access to specific registrars if they're
// not admins
google.registry.model.console.User consoleUser =
new google.registry.model.console.User.Builder()
User consoleUser =
new User.Builder()
.setEmailAddress("email@email.com")
.setUserRoles(new UserRoles.Builder().setGlobalRole(GlobalRole.SUPPORT_AGENT).build())
.build();
@@ -425,8 +425,8 @@ class AuthenticatedRegistrarAccessorTest {
@Test
void testConsoleUser_registrarRoles() {
// Registrar employees should have OWNER access to their registrars
google.registry.model.console.User consoleUser =
new google.registry.model.console.User.Builder()
User consoleUser =
new User.Builder()
.setEmailAddress("email@email.com")
.setUserRoles(
new UserRoles.Builder()

View File

@@ -136,9 +136,7 @@ public final class DomainSubject extends AbstractEppResourceSubject<Domain, Doma
}
public And<DomainSubject> hasNoAutorenewEndTime() {
return hasNoValue(
actual.getAutorenewEndTime().map(google.registry.util.DateTimeUtils::toInstant),
"getAutorenewEndTime()");
return hasNoValue(actual.getAutorenewEndTimeInstant(), "getAutorenewEndTime()");
}
public static SimpleSubjectBuilder<DomainSubject, Domain> assertAboutDomains() {

View File

@@ -133,6 +133,9 @@ tasks.withType(JavaCompile).configureEach {
// Allow assignment to injected variables: too many to fix.
options.errorprone.disable("UnnecessaryAssignment")
// Report unnecessarily fully qualified names as warnings.
options.errorprone.warn("UnnecessarilyFullyQualified")
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.errorproneArgumentProviders.add([
asArguments: {