Fix Java code clarity and Error Prone warnings.
Change-Id: I04e66fc6ebdc227f8058d969a0f46aa1de46c0c5
This commit is contained in:
@@ -339,7 +339,7 @@ public interface ChangeApi {
|
|||||||
* @return comments as a list; comments have the {@code revision} field set to indicate their
|
* @return comments as a list; comments have the {@code revision} field set to indicate their
|
||||||
* patch set.
|
* patch set.
|
||||||
* @throws RestApiException
|
* @throws RestApiException
|
||||||
* @deprecate Callers should use {@link #commentsRequest()} instead
|
* @deprecated Callers should use {@link #commentsRequest()} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default List<CommentInfo> commentsAsList() throws RestApiException {
|
default List<CommentInfo> commentsAsList() throws RestApiException {
|
||||||
@@ -351,7 +351,6 @@ public interface ChangeApi {
|
|||||||
*
|
*
|
||||||
* @return A {@link CommentsRequest} entity that can be used to retrieve the comments using the
|
* @return A {@link CommentsRequest} entity that can be used to retrieve the comments using the
|
||||||
* {@link CommentsRequest#get()} or {@link CommentsRequest#getAsList()}.
|
* {@link CommentsRequest#get()} or {@link CommentsRequest#getAsList()}.
|
||||||
* @throws RestApiException
|
|
||||||
*/
|
*/
|
||||||
CommentsRequest commentsRequest() throws RestApiException;
|
CommentsRequest commentsRequest() throws RestApiException;
|
||||||
|
|
||||||
@@ -429,7 +428,6 @@ public interface ChangeApi {
|
|||||||
*
|
*
|
||||||
* @return comments as a list; comments have the {@code revision} field set to indicate their
|
* @return comments as a list; comments have the {@code revision} field set to indicate their
|
||||||
* patch set.
|
* patch set.
|
||||||
* @throws RestApiException
|
|
||||||
*/
|
*/
|
||||||
public abstract List<CommentInfo> getAsList() throws RestApiException;
|
public abstract List<CommentInfo> getAsList() throws RestApiException;
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class CommentContextLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CommentContextLoader(GitRepositoryManager repoManager, @Assisted Project.NameKey project) {
|
CommentContextLoader(GitRepositoryManager repoManager, @Assisted Project.NameKey project) {
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.candidates = new HashMap<>();
|
this.candidates = new HashMap<>();
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
|||||||
import com.google.gerrit.extensions.restapi.Response;
|
import com.google.gerrit.extensions.restapi.Response;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.CommentContextLoader;
|
|
||||||
import com.google.gerrit.server.CommentsUtil;
|
import com.google.gerrit.server.CommentsUtil;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -42,7 +41,6 @@ public class ListChangeComments implements RestReadView<ChangeResource> {
|
|||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Provider<CommentJson> commentJson;
|
private final Provider<CommentJson> commentJson;
|
||||||
private final CommentsUtil commentsUtil;
|
private final CommentsUtil commentsUtil;
|
||||||
private final CommentContextLoader.Factory commentContextFactory;
|
|
||||||
|
|
||||||
private boolean includeContext;
|
private boolean includeContext;
|
||||||
|
|
||||||
@@ -62,13 +60,11 @@ public class ListChangeComments implements RestReadView<ChangeResource> {
|
|||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
Provider<CommentJson> commentJson,
|
Provider<CommentJson> commentJson,
|
||||||
CommentsUtil commentsUtil,
|
CommentsUtil commentsUtil,
|
||||||
ChangeMessagesUtil changeMessagesUtil,
|
ChangeMessagesUtil changeMessagesUtil) {
|
||||||
CommentContextLoader.Factory commentContextFactory) {
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.commentJson = commentJson;
|
this.commentJson = commentJson;
|
||||||
this.commentsUtil = commentsUtil;
|
this.commentsUtil = commentsUtil;
|
||||||
this.changeMessagesUtil = changeMessagesUtil;
|
this.changeMessagesUtil = changeMessagesUtil;
|
||||||
this.commentContextFactory = commentContextFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
|||||||
import org.eclipse.jgit.lib.Config;
|
import org.eclipse.jgit.lib.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap a (@link {@link SubscriptionGraph.Factory} to honor the gerrit configuration.
|
* Wrap a {@link SubscriptionGraph.Factory} to honor the gerrit configuration.
|
||||||
*
|
*
|
||||||
* <p>If superproject subscriptions are disabled in the conf, return an empty graph.
|
* <p>If superproject subscriptions are disabled in the conf, return an empty graph.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -227,7 +227,6 @@ public class MergeOp implements AutoCloseable {
|
|||||||
private final Provider<InternalChangeQuery> queryProvider;
|
private final Provider<InternalChangeQuery> queryProvider;
|
||||||
private final SubmitStrategyFactory submitStrategyFactory;
|
private final SubmitStrategyFactory submitStrategyFactory;
|
||||||
private final SubscriptionGraph.Factory subscriptionGraphFactory;
|
private final SubscriptionGraph.Factory subscriptionGraphFactory;
|
||||||
private final SubmoduleOp.Factory subOpFactory;
|
|
||||||
private final SubmoduleCommits.Factory submoduleCommitsFactory;
|
private final SubmoduleCommits.Factory submoduleCommitsFactory;
|
||||||
private final Provider<MergeOpRepoManager> ormProvider;
|
private final Provider<MergeOpRepoManager> ormProvider;
|
||||||
private final NotifyResolver notifyResolver;
|
private final NotifyResolver notifyResolver;
|
||||||
@@ -260,7 +259,6 @@ public class MergeOp implements AutoCloseable {
|
|||||||
SubmitStrategyFactory submitStrategyFactory,
|
SubmitStrategyFactory submitStrategyFactory,
|
||||||
SubmoduleCommits.Factory submoduleCommitsFactory,
|
SubmoduleCommits.Factory submoduleCommitsFactory,
|
||||||
SubscriptionGraph.Factory subscriptionGraphFactory,
|
SubscriptionGraph.Factory subscriptionGraphFactory,
|
||||||
SubmoduleOp.Factory subOpFactory,
|
|
||||||
Provider<MergeOpRepoManager> ormProvider,
|
Provider<MergeOpRepoManager> ormProvider,
|
||||||
NotifyResolver notifyResolver,
|
NotifyResolver notifyResolver,
|
||||||
TopicMetrics topicMetrics,
|
TopicMetrics topicMetrics,
|
||||||
@@ -275,7 +273,6 @@ public class MergeOp implements AutoCloseable {
|
|||||||
this.submitStrategyFactory = submitStrategyFactory;
|
this.submitStrategyFactory = submitStrategyFactory;
|
||||||
this.submoduleCommitsFactory = submoduleCommitsFactory;
|
this.submoduleCommitsFactory = submoduleCommitsFactory;
|
||||||
this.subscriptionGraphFactory = subscriptionGraphFactory;
|
this.subscriptionGraphFactory = subscriptionGraphFactory;
|
||||||
this.subOpFactory = subOpFactory;
|
|
||||||
this.ormProvider = ormProvider;
|
this.ormProvider = ormProvider;
|
||||||
this.notifyResolver = notifyResolver;
|
this.notifyResolver = notifyResolver;
|
||||||
this.retryHelper = retryHelper;
|
this.retryHelper = retryHelper;
|
||||||
@@ -754,7 +751,7 @@ public class MergeOp implements AutoCloseable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
abstract SubmitType submitType();
|
abstract SubmitType submitType();
|
||||||
|
|
||||||
abstract Set<CodeReviewCommit> commits();
|
abstract ImmutableSet<CodeReviewCommit> commits();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BranchBatch validateChangeList(OpenRepo or, Collection<ChangeData> submitted) {
|
private BranchBatch validateChangeList(OpenRepo or, Collection<ChangeData> submitted) {
|
||||||
@@ -869,7 +866,7 @@ public class MergeOp implements AutoCloseable {
|
|||||||
toSubmit.add(commit);
|
toSubmit.add(commit);
|
||||||
}
|
}
|
||||||
logger.atFine().log("Submitting on this run: %s", toSubmit);
|
logger.atFine().log("Submitting on this run: %s", toSubmit);
|
||||||
return new AutoValue_MergeOp_BranchBatch(submitType, toSubmit);
|
return new AutoValue_MergeOp_BranchBatch(submitType, ImmutableSet.copyOf(toSubmit));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SetMultimap<ObjectId, PatchSet.Id> getRevisions(OpenRepo or, Collection<ChangeData> cds) {
|
private SetMultimap<ObjectId, PatchSet.Id> getRevisions(OpenRepo or, Collection<ChangeData> cds) {
|
||||||
|
|||||||
@@ -1775,7 +1775,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addComment(PushOneCommit.Result r, String message) throws Exception {
|
private void addComment(PushOneCommit.Result r, String message) throws Exception {
|
||||||
addComment(r, message, false, false, null, 1, null);
|
addComment(r, message, false, false, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCommentOnLine(PushOneCommit.Result r, String message, int line) throws Exception {
|
private void addCommentOnLine(PushOneCommit.Result r, String message, int line) throws Exception {
|
||||||
@@ -1801,7 +1801,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
|||||||
Boolean unresolved,
|
Boolean unresolved,
|
||||||
String inReplyTo)
|
String inReplyTo)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
addComment(r, message, omitDuplicateComments, unresolved, inReplyTo, 1, null);
|
addComment(r, message, omitDuplicateComments, unresolved, inReplyTo, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addComment(
|
private void addComment(
|
||||||
@@ -1814,7 +1814,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
|||||||
Comment.Range range)
|
Comment.Range range)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
CommentInput c = new CommentInput();
|
CommentInput c = new CommentInput();
|
||||||
c.line = 1;
|
c.line = line == null ? 1 : line;
|
||||||
c.message = message;
|
c.message = message;
|
||||||
c.path = FILE_NAME;
|
c.path = FILE_NAME;
|
||||||
c.unresolved = unresolved;
|
c.unresolved = unresolved;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
import static com.google.common.truth.Truth.assertWithMessage;
|
import static com.google.common.truth.Truth.assertWithMessage;
|
||||||
import static com.google.common.truth.Truth8.assertThat;
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -53,8 +52,11 @@ import org.eclipse.jgit.lib.RefUpdate;
|
|||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.MockitoJUnit;
|
||||||
|
import org.mockito.junit.MockitoRule;
|
||||||
|
|
||||||
public class SubmoduleCommitsTest {
|
public class SubmoduleCommitsTest {
|
||||||
|
|
||||||
@@ -67,8 +69,9 @@ public class SubmoduleCommitsTest {
|
|||||||
private InMemoryRepositoryManager repoManager = new InMemoryRepositoryManager();
|
private InMemoryRepositoryManager repoManager = new InMemoryRepositoryManager();
|
||||||
private MergeOpRepoManager mergeOpRepoManager;
|
private MergeOpRepoManager mergeOpRepoManager;
|
||||||
|
|
||||||
@Mock ProjectCache mockProjectCache = mock(ProjectCache.class);
|
@Rule public final MockitoRule mockito = MockitoJUnit.rule();
|
||||||
@Mock ProjectState mockProjectState = mock(ProjectState.class);
|
@Mock private ProjectCache mockProjectCache;
|
||||||
|
@Mock private ProjectState mockProjectState;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createGitlinksCommit_subprojectMoved() throws Exception {
|
public void createGitlinksCommit_subprojectMoved() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user