Fix Java code clarity and Error Prone warnings.

Change-Id: I04e66fc6ebdc227f8058d969a0f46aa1de46c0c5
This commit is contained in:
Youssef Elghareeb
2020-09-22 10:45:52 +02:00
parent 4dc29c8b11
commit f073e81de9
7 changed files with 15 additions and 21 deletions

View File

@@ -339,7 +339,7 @@ public interface ChangeApi {
* @return comments as a list; comments have the {@code revision} field set to indicate their
* patch set.
* @throws RestApiException
* @deprecate Callers should use {@link #commentsRequest()} instead
* @deprecated Callers should use {@link #commentsRequest()} instead
*/
@Deprecated
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
* {@link CommentsRequest#get()} or {@link CommentsRequest#getAsList()}.
* @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
* patch set.
* @throws RestApiException
*/
public abstract List<CommentInfo> getAsList() throws RestApiException;

View File

@@ -55,7 +55,7 @@ public class CommentContextLoader {
}
@Inject
public CommentContextLoader(GitRepositoryManager repoManager, @Assisted Project.NameKey project) {
CommentContextLoader(GitRepositoryManager repoManager, @Assisted Project.NameKey project) {
this.repoManager = repoManager;
this.project = project;
this.candidates = new HashMap<>();

View File

@@ -26,7 +26,6 @@ import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.ChangeMessagesUtil;
import com.google.gerrit.server.CommentContextLoader;
import com.google.gerrit.server.CommentsUtil;
import com.google.gerrit.server.change.ChangeResource;
import com.google.gerrit.server.permissions.PermissionBackendException;
@@ -42,7 +41,6 @@ public class ListChangeComments implements RestReadView<ChangeResource> {
private final ChangeData.Factory changeDataFactory;
private final Provider<CommentJson> commentJson;
private final CommentsUtil commentsUtil;
private final CommentContextLoader.Factory commentContextFactory;
private boolean includeContext;
@@ -62,13 +60,11 @@ public class ListChangeComments implements RestReadView<ChangeResource> {
ChangeData.Factory changeDataFactory,
Provider<CommentJson> commentJson,
CommentsUtil commentsUtil,
ChangeMessagesUtil changeMessagesUtil,
CommentContextLoader.Factory commentContextFactory) {
ChangeMessagesUtil changeMessagesUtil) {
this.changeDataFactory = changeDataFactory;
this.commentJson = commentJson;
this.commentsUtil = commentsUtil;
this.changeMessagesUtil = changeMessagesUtil;
this.commentContextFactory = commentContextFactory;
}
@Override

View File

@@ -23,7 +23,7 @@ import java.util.Set;
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.
*/

View File

@@ -227,7 +227,6 @@ public class MergeOp implements AutoCloseable {
private final Provider<InternalChangeQuery> queryProvider;
private final SubmitStrategyFactory submitStrategyFactory;
private final SubscriptionGraph.Factory subscriptionGraphFactory;
private final SubmoduleOp.Factory subOpFactory;
private final SubmoduleCommits.Factory submoduleCommitsFactory;
private final Provider<MergeOpRepoManager> ormProvider;
private final NotifyResolver notifyResolver;
@@ -260,7 +259,6 @@ public class MergeOp implements AutoCloseable {
SubmitStrategyFactory submitStrategyFactory,
SubmoduleCommits.Factory submoduleCommitsFactory,
SubscriptionGraph.Factory subscriptionGraphFactory,
SubmoduleOp.Factory subOpFactory,
Provider<MergeOpRepoManager> ormProvider,
NotifyResolver notifyResolver,
TopicMetrics topicMetrics,
@@ -275,7 +273,6 @@ public class MergeOp implements AutoCloseable {
this.submitStrategyFactory = submitStrategyFactory;
this.submoduleCommitsFactory = submoduleCommitsFactory;
this.subscriptionGraphFactory = subscriptionGraphFactory;
this.subOpFactory = subOpFactory;
this.ormProvider = ormProvider;
this.notifyResolver = notifyResolver;
this.retryHelper = retryHelper;
@@ -754,7 +751,7 @@ public class MergeOp implements AutoCloseable {
@Nullable
abstract SubmitType submitType();
abstract Set<CodeReviewCommit> commits();
abstract ImmutableSet<CodeReviewCommit> commits();
}
private BranchBatch validateChangeList(OpenRepo or, Collection<ChangeData> submitted) {
@@ -869,7 +866,7 @@ public class MergeOp implements AutoCloseable {
toSubmit.add(commit);
}
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) {

View File

@@ -1775,7 +1775,7 @@ public class CommentsIT extends AbstractDaemonTest {
}
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 {
@@ -1801,7 +1801,7 @@ public class CommentsIT extends AbstractDaemonTest {
Boolean unresolved,
String inReplyTo)
throws Exception {
addComment(r, message, omitDuplicateComments, unresolved, inReplyTo, 1, null);
addComment(r, message, omitDuplicateComments, unresolved, inReplyTo, null, null);
}
private void addComment(
@@ -1814,7 +1814,7 @@ public class CommentsIT extends AbstractDaemonTest {
Comment.Range range)
throws Exception {
CommentInput c = new CommentInput();
c.line = 1;
c.line = line == null ? 1 : line;
c.message = message;
c.path = FILE_NAME;
c.unresolved = unresolved;

View File

@@ -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.Truth8.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
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.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
public class SubmoduleCommitsTest {
@@ -67,8 +69,9 @@ public class SubmoduleCommitsTest {
private InMemoryRepositoryManager repoManager = new InMemoryRepositoryManager();
private MergeOpRepoManager mergeOpRepoManager;
@Mock ProjectCache mockProjectCache = mock(ProjectCache.class);
@Mock ProjectState mockProjectState = mock(ProjectState.class);
@Rule public final MockitoRule mockito = MockitoJUnit.rule();
@Mock private ProjectCache mockProjectCache;
@Mock private ProjectState mockProjectState;
@Test
public void createGitlinksCommit_subprojectMoved() throws Exception {