Turn on many more Eclipse warnings, and fix them

- Warn on empty statements, e.g. "for (;;);". These may be
   typos and are easily replaced by "for (;;) {}" which is more
   explicit.
 - Warn on field hiding. This allows cleanup of many acceptance test
   members, at the cost of a couple of renames and the occasional
   suppression (when the field is in a public nested enum that shadows
   a public constant).
 - Warn on unnecessary casts.
 - Warn on unused declared thrown exceptions. In addition to reducing
   method signature length and number of imports, this also eliminated
   some impossible catch blocks.
 - Warn on missing @Override annotations.
 - Warn on unused parameters. This is likely the most controversial,
   as a few relatively common patterns require unused parameters in a
   way that Eclipse can't ignore. However, it also resulted in cleanup
   of a lot of unnecessary injections and method parameters, so I
   think the cost was worth it.

Change-Id: I7224be8b1c798613a127c88507e8cce400679e5d
This commit is contained in:
Dave Borowitz
2014-10-28 12:09:55 -07:00
parent 2e82f2f8a2
commit 8b42ec5bd5
305 changed files with 932 additions and 699 deletions

View File

@@ -96,6 +96,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
final String newName = groupNameTxt.getText().trim();
GroupApi.renameGroup(getGroupUUID(), newName,
new GerritCallback<com.google.gerrit.client.VoidResult>() {
@Override
public void onSuccess(final com.google.gerrit.client.VoidResult result) {
saveName.setEnabled(false);
setPageTitle(Util.M.group(newName));
@@ -135,6 +136,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
String ownerId = ownerUuid != null ? ownerUuid.get() : newOwner;
GroupApi.setGroupOwner(getGroupUUID(), ownerId,
new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(final GroupInfo result) {
updateOwnerGroup(result);
saveOwner.setEnabled(false);
@@ -165,6 +167,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
final String txt = descTxt.getText().trim();
GroupApi.setGroupDescription(getGroupUUID(), txt,
new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) {
saveDesc.setEnabled(false);
}
@@ -193,6 +196,7 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
public void onClick(final ClickEvent event) {
GroupApi.setGroupOptions(getGroupUUID(),
visibleToAllCheckBox.getValue(), new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) {
saveGroupOptions.setEnabled(false);
}

View File

@@ -172,6 +172,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
addMemberBox.setEnabled(false);
GroupApi.addMember(getGroupUUID(), nameEmail,
new GerritCallback<AccountInfo>() {
@Override
public void onSuccess(final AccountInfo memberInfo) {
addMemberBox.setEnabled(true);
addMemberBox.setText("");
@@ -200,6 +201,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
addIncludeBox.setEnabled(false);
GroupApi.addIncludedGroup(getGroupUUID(), uuid.get(),
new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(final GroupInfo result) {
addIncludeBox.setEnabled(true);
addIncludeBox.setText("");
@@ -248,6 +250,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
if (!ids.isEmpty()) {
GroupApi.removeMembers(getGroupUUID(), ids,
new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) {
for (int row = 1; row < table.getRowCount();) {
final AccountInfo i = getRowItem(row);
@@ -353,6 +356,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
if (!ids.isEmpty()) {
GroupApi.removeIncludedGroups(getGroupUUID(), ids,
new GerritCallback<VoidResult>() {
@Override
public void onSuccess(final VoidResult result) {
for (int row = 1; row < table.getRowCount();) {
final GroupInfo i = getRowItem(row);

View File

@@ -128,6 +128,7 @@ public class CreateGroupScreen extends Screen {
addNew.setEnabled(false);
GroupApi.createGroup(newName, new GerritCallback<GroupInfo>() {
@Override
public void onSuccess(final GroupInfo result) {
History.newItem(Dispatcher.toGroup(result.getGroupId(),
AccountGroupScreen.MEMBERS));

View File

@@ -133,6 +133,7 @@ public class GroupReferenceBox extends Composite implements
suggestBox.setTabIndex(index);
}
@Override
public void setFocus(boolean focused) {
suggestBox.setFocus(focused);
}

View File

@@ -316,6 +316,7 @@ public class ProjectBranchesScreen extends ProjectScreen {
private void deleteBranches(final Set<String> branches) {
ProjectApi.deleteBranches(getProjectKey(), branches,
new GerritCallback<VoidResult>() {
@Override
public void onSuccess(VoidResult result) {
for (int row = 1; row < table.getRowCount();) {
BranchInfo k = getRowItem(row);

View File

@@ -27,16 +27,19 @@ import java.text.ParseException;
public class RefPatternBox extends ValueBox<String> {
private static final Renderer<String> RENDERER = new Renderer<String>() {
@Override
public String render(String ref) {
return ref;
}
@Override
public void render(String ref, Appendable dst) throws IOException {
dst.append(render(ref));
}
};
private static final Parser<String> PARSER = new Parser<String>() {
@Override
public String parse(CharSequence text) throws ParseException {
String ref = text.toString();

View File

@@ -86,6 +86,7 @@ public class ValueEditor<T> extends Composite implements HasEditorErrors<T>,
editPanel.setVisible(true);
}
@Override
public ValueBoxEditor<T> asEditor() {
if (editProxy == null) {
editProxy = new EditorProxy();
@@ -133,6 +134,7 @@ public class ValueEditor<T> extends Composite implements HasEditorErrors<T>,
startHandlers.enabled = enabled;
}
@Override
public void showErrors(List<EditorError> errors) {
StringBuilder buf = new StringBuilder();
for (EditorError error : errors) {