Remove unused value assignments

IntelliJ > Run Inspection by name > Unused assignments

Change-Id: Iecf5a5f430b08c5a29a1ba2a363c3de6506bfdde
This commit is contained in:
Patrick Hiesel
2018-09-20 14:31:14 +02:00
parent 734205471b
commit 4746349d41
29 changed files with 42 additions and 55 deletions

View File

@@ -182,11 +182,6 @@ public class MyWatchedProjectsScreen extends SettingsScreen {
return;
}
String filter = filterTxt.getText();
if (filter == null || filter.isEmpty() || filter.equals(Util.C.defaultFilter())) {
filter = null;
}
addNew.setEnabled(false);
nameBox.setEnabled(false);
filterTxt.setEnabled(false);

View File

@@ -201,8 +201,8 @@ public class LocalComments {
private static InlineComment getInlineComment(String key) {
String path;
Side side = Side.PARENT;
int line = 0;
Side side;
int line;
CommentRange range;
StorageBackend storage = new StorageBackend();

View File

@@ -118,7 +118,7 @@ class ProjectOAuthFilter implements Filter {
}
private boolean verify(HttpServletRequest req, Response rsp) throws IOException {
AuthInfo authInfo = null;
AuthInfo authInfo;
// first check if there is a BASIC authentication header
String hdr = req.getHeader(AUTHORIZATION);

View File

@@ -120,7 +120,7 @@ class OAuthSessionOverOpenID {
com.google.gerrit.server.account.AuthRequest areq =
new com.google.gerrit.server.account.AuthRequest(
ExternalId.Key.parse(user.getExternalId()));
AuthResult arsp = null;
AuthResult arsp;
try {
String claimedIdentifier = user.getClaimedIdentity();
Optional<Account.Id> actualId = accountManager.lookup(user.getExternalId());

View File

@@ -543,7 +543,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements Per
try (Statement s = c.conn.createStatement()) {
// Compute size without restricting to version (although obsolete data was just pruned
// anyway).
long used = 0;
long used;
try (ResultSet r = s.executeQuery("SELECT SUM(space) FROM data")) {
used = r.next() ? r.getLong(1) : 0;
}

View File

@@ -1308,7 +1308,7 @@ public class ChangeJson {
RevWalk rw = newRevWalk(repo)) {
for (PatchSet in : map.values()) {
PatchSet.Id id = in.getId();
boolean want = false;
boolean want;
if (has(ALL_REVISIONS)) {
want = true;
} else if (limitToPsId.isPresent()) {

View File

@@ -128,7 +128,7 @@ public class ReplaceOp implements BatchUpdateOp {
private final PatchSetInfo info;
private final MagicBranchInput magicBranch;
private final PushCertificate pushCertificate;
private List<String> groups = ImmutableList.of();
private List<String> groups;
private final Map<String, Short> approvals = new HashMap<>();
private final MailRecipients recipients = new MailRecipients();

View File

@@ -507,7 +507,7 @@ public class CommentSender extends ReplyToChangeSender {
@Override
protected void setupSoyContext() {
super.setupSoyContext();
boolean hasComments = false;
boolean hasComments;
try (Repository repo = getRepository()) {
List<Map<String, Object>> files = getCommentGroupsTemplateData(repo);
soyContext.put("commentFiles", files);

View File

@@ -185,11 +185,11 @@ public class PatchListLoader implements Callable<PatchList> {
df.setDetectRenames(true);
List<DiffEntry> diffEntries = df.scan(aTree, bTree);
Multimap<String, ContextAwareEdit> editsDueToRebasePerFilePath = ImmutableMultimap.of();
EditsDueToRebaseResult editsDueToRebaseResult =
determineEditsDueToRebase(aCommit, b, diffEntries, df, rw);
diffEntries = editsDueToRebaseResult.getRelevantOriginalDiffEntries();
editsDueToRebasePerFilePath = editsDueToRebaseResult.getEditsDueToRebasePerFilePath();
Multimap<String, ContextAwareEdit> editsDueToRebasePerFilePath =
editsDueToRebaseResult.getEditsDueToRebasePerFilePath();
List<PatchListEntry> entries = new ArrayList<>();
entries.add(

View File

@@ -176,7 +176,7 @@ public class PostReviewers
String reviewer = input.reviewer;
ReviewerState state = input.state();
NotifyHandling notify = input.notify;
ListMultimap<RecipientType, Account.Id> accountsToNotify = null;
ListMultimap<RecipientType, Account.Id> accountsToNotify;
try {
accountsToNotify = notifyUtil.resolveAccounts(input.notifyDetails);
} catch (BadRequestException e) {
@@ -233,7 +233,7 @@ public class PostReviewers
boolean allowGroup,
boolean allowByEmail)
throws OrmException, PermissionBackendException, IOException, ConfigInvalidException {
IdentifiedUser reviewerUser = null;
IdentifiedUser reviewerUser;
boolean exactMatchFound = false;
try {
reviewerUser = accounts.parse(reviewer);
@@ -287,7 +287,7 @@ public class PostReviewers
return null;
}
GroupDescription.Basic group = null;
GroupDescription.Basic group;
try {
group = groupsCollection.parseInternal(reviewer);
} catch (UnprocessableEntityException e) {

View File

@@ -93,7 +93,7 @@ public class CheckAccess implements RestModifyView<ProjectResource, AccessCheckI
return info;
}
RefPermission refPerm = null;
RefPermission refPerm;
if (!Strings.isNullOrEmpty(input.permission)) {
if (Strings.isNullOrEmpty(input.ref)) {
throw new BadRequestException("must set 'ref' when specifying 'permission'");

View File

@@ -279,7 +279,7 @@ public class DeleteRef {
}
private void appendAndLogErrorMessage(StringBuilder errorMessages, ReceiveCommand cmd) {
String msg = null;
String msg;
switch (cmd.getResult()) {
case REJECTED_CURRENT_BRANCH:
msg = format("Cannot delete %s: it is the current branch", cmd.getRefName());

View File

@@ -188,7 +188,7 @@ public class MergeSuperSet {
Set<String> topicsSeen = new HashSet<>();
Set<String> visibleTopicsSeen = new HashSet<>();
int oldSeen;
int seen = 0;
int seen;
changeSet = topicClosure(db, changeSet, user, topicsSeen, visibleTopicsSeen);
seen = topicsSeen.size() + visibleTopicsSeen.size();

View File

@@ -217,8 +217,6 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
logger.atFine().log(
"%s#updateChange for change %s", getClass().getSimpleName(), toMerge.change().getId());
toMerge.setNotes(ctx.getNotes()); // Update change and notes from ctx.
PatchSet.Id oldPsId = checkNotNull(toMerge.getPatchsetId());
PatchSet.Id newPsId;
if (ctx.getChange().getStatus() == Change.Status.MERGED) {
// Either another thread won a race, or we are retrying a whole topic submission after one
@@ -238,10 +236,10 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
if (alreadyMergedCommit != null) {
alreadyMergedCommit.setNotes(ctx.getNotes());
mergedPatchSet = getOrCreateAlreadyMergedPatchSet(ctx);
newPsId = mergedPatchSet.getId();
} else {
PatchSet newPatchSet = updateChangeImpl(ctx);
newPsId = checkNotNull(ctx.getChange().currentPatchSetId());
PatchSet.Id oldPsId = checkNotNull(toMerge.getPatchsetId());
PatchSet.Id newPsId = checkNotNull(ctx.getChange().currentPatchSetId());
if (newPatchSet == null) {
checkState(
oldPsId.equals(newPsId),

View File

@@ -453,7 +453,7 @@ public class CmdLineParser {
for (Class<?> c = bean.getClass(); c != null; c = c.getSuperclass()) {
for (Field f : c.getDeclaredFields()) {
if (f.isAnnotationPresent(Options.class)) {
Object additionalBean = null;
Object additionalBean;
try {
additionalBean = f.get(bean);
} catch (IllegalAccessException e) {

View File

@@ -1977,12 +1977,10 @@ public class AccountIT extends AbstractDaemonTest {
exception.expect(BadRequestException.class);
exception.expectMessage("Cannot both add and delete key: " + keyToString(key2.getPublicKey()));
infos =
gApi.accounts()
.self()
.putGpgKeys(
ImmutableList.of(key2.getPublicKeyArmored()),
ImmutableList.of(key2.getKeyIdString()));
gApi.accounts()
.self()
.putGpgKeys(
ImmutableList.of(key2.getPublicKeyArmored()), ImmutableList.of(key2.getKeyIdString()));
}
@Test

View File

@@ -307,11 +307,11 @@ public class ProjectIT extends AbstractDaemonTest {
@Test
public void setPartialConfig() throws Exception {
ConfigInput input = createTestConfigInput();
ConfigInfo info = gApi.projects().name(project.get()).config(input);
gApi.projects().name(project.get()).config(input);
ConfigInput partialInput = new ConfigInput();
partialInput.useContributorAgreements = InheritableBoolean.FALSE;
info = gApi.projects().name(project.get()).config(partialInput);
ConfigInfo info = gApi.projects().name(project.get()).config(partialInput);
assertThat(info.description).isNull();
assertThat(info.useContributorAgreements.configuredValue)

View File

@@ -1305,7 +1305,7 @@ public class RevisionIT extends AbstractDaemonTest {
oldETag = checkETag(getRevisionActions, r2, oldETag);
current(r2).submit();
oldETag = checkETag(getRevisionActions, r2, oldETag);
checkETag(getRevisionActions, r2, oldETag);
}
@Test

View File

@@ -500,7 +500,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
// request that sender gets notified as TO, CC and BCC, email should be sent
// even if the sender is the only recipient
sender.clear();
r = pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-to=" + admin.email);
pushTo(pushSpec + ",notify=" + NotifyHandling.NONE + ",notify-to=" + admin.email);
assertNotifyTo(admin);
sender.clear();
@@ -1972,7 +1972,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
assertThat(getPublishedComments(id1)).isEmpty();
assertThat(getPublishedComments(id2)).isEmpty();
r2 = amendChange(id2, "refs/for/master%publish-comments");
amendChange(id2, "refs/for/master%publish-comments");
assertThat(getPublishedComments(id1)).isEmpty();
assertThat(gApi.changes().id(id1).drafts()).hasSize(1);

View File

@@ -613,8 +613,9 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
TestRepository<?> superRepo = createProjectWithPush("super-project");
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
TestRepository<?> subRepo2 = createProjectWithPush("subscribed-to-project-2");
subRepo2 = cloneProject(new Project.NameKey(name("subscribed-to-project-2")), user);
createProjectWithPush("subscribed-to-project-2");
TestRepository<?> subRepo2 =
cloneProject(new Project.NameKey(name("subscribed-to-project-2")), user);
allowMatchingSubmoduleSubscription(
"subscribed-to-project", "refs/heads/master", "super-project", "refs/heads/master");

View File

@@ -394,10 +394,7 @@ public class ActionsIT extends AbstractDaemonTest {
// ...via ChangeJson directly.
ChangeData cd = changeDataFactory.create(db, project, changeId);
revisionInfo =
changeJsonFactory
.create(opts)
.getRevisionInfo(cd, cd.patchSet(new PatchSet.Id(changeId, 1)));
changeJsonFactory.create(opts).getRevisionInfo(cd, cd.patchSet(new PatchSet.Id(changeId, 1)));
}
private void visitedCurrentRevisionActionsAssertions(

View File

@@ -180,7 +180,7 @@ public class CorsIT extends AbstractDaemonTest {
Executor http = Executor.newInstance().cookieStore(cookies);
Request req = Request.Get(canonicalWebUrl.get() + "/login/?account_id=" + admin.id.get());
HttpResponse r = http.execute(req).returnResponse();
http.execute(req);
String auth = null;
for (Cookie c : cookies.getCookies()) {
if ("GerritAccount".equals(c.getName())) {
@@ -202,7 +202,7 @@ public class CorsIT extends AbstractDaemonTest {
req.setHeader(ORIGIN, origin);
req.bodyByteArray("{\"topic\":\"test-xd\"}".getBytes(StandardCharsets.US_ASCII));
r = http.execute(req).returnResponse();
HttpResponse r = http.execute(req).returnResponse();
assertThat(r.getStatusLine().getStatusCode()).isEqualTo(200);
Header vary = r.getFirstHeader(VARY);

View File

@@ -529,7 +529,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
List<String> untarredFiles = new ArrayList<>();
try (TarArchiveInputStream tarInputStream =
(TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", is)) {
TarArchiveEntry entry = null;
TarArchiveEntry entry;
while ((entry = (TarArchiveEntry) tarInputStream.getNextEntry()) != null) {
untarredFiles.add(entry.getName());
}

View File

@@ -84,7 +84,7 @@ public class PatchListCacheIT extends AbstractDaemonTest {
assertDeleted(FILE_D, entries.get(2));
// Change 1,2 (+FILE_A, +FILE_B, -FILE_D)
c = amendBuilder().add(FILE_B, "2").create();
amendBuilder().add(FILE_B, "2").create();
pushHead(testRepo, "refs/for/master", false);
entries = getCurrentPatches(id);

View File

@@ -191,7 +191,7 @@ public class ChangeRebuilderIT extends AbstractDaemonTest {
public void patchSets() throws Exception {
PushOneCommit.Result r = createChange();
Change.Id id = r.getPatchSetId().getParentKey();
r = amendChange(r.getChangeId());
amendChange(r.getChangeId());
checker.rebuildAndCheckChanges(id);
}

View File

@@ -75,7 +75,7 @@ public class UploadArchiveIT extends AbstractDaemonTest {
PacketLineIn in = new PacketLineIn(out);
String tmp = in.readString();
assertThat(tmp).isEqualTo("ACK");
tmp = in.readString();
in.readString();
// Skip length (4 bytes) + 1 byte
// to position the output stream to the raw zip stream
@@ -150,7 +150,7 @@ public class UploadArchiveIT extends AbstractDaemonTest {
PacketLineIn in = new PacketLineIn(out);
String tmp = in.readString();
assertThat(tmp).isEqualTo("ACK");
tmp = in.readString();
in.readString();
tmp = in.readString();
tmp = tmp.substring(1);
assertThat(tmp).isEqualTo("fatal: upload-archive not permitted for format zip");

View File

@@ -721,8 +721,6 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.setAssignee(otherUserId);
update.commit();
ChangeNotes notes = newNotes(c);
update = newUpdate(c, changeOwner);
update.setAssignee(changeOwner.getAccountId());
update.commit();
@@ -735,7 +733,7 @@ public class ChangeNotesTest extends AbstractChangeNotesTest {
update.removeAssignee();
update.commit();
notes = newNotes(c);
ChangeNotes notes = newNotes(c);
assertThat(notes.getPastAssignees()).hasSize(2);
}

View File

@@ -1955,7 +1955,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
actual = assertQuery(newQuery("-is:reviewed").withOption(REVIEWED), change1);
assertThat(actual.get(0).reviewed).isNull();
actual = assertQuery("reviewedby:" + userId.get());
assertQuery("reviewedby:" + userId.get());
actual =
assertQuery(newQuery("reviewedby:" + user2.get()).withOption(REVIEWED), change3, change2);

View File

@@ -269,7 +269,7 @@ public abstract class AbstractQueryProjectsTest extends GerritServerTests {
"name:" + project1.name + " OR name:" + project2.name + " OR name:" + project3.name;
List<ProjectInfo> result = assertQuery(query, project1, project2, project3);
result = assertQuery(newQuery(query).withLimit(2), result.subList(0, 2));
assertQuery(newQuery(query).withLimit(2), result.subList(0, 2));
}
@Test