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:
@@ -18,9 +18,7 @@ import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.account.GroupDetailFactory.Factory;
|
||||
@@ -64,13 +62,12 @@ public class ListMembersCommand extends SshCommand {
|
||||
@Inject
|
||||
protected ListMembersCommandImpl(GroupCache groupCache,
|
||||
Factory groupDetailFactory,
|
||||
AccountInfo.Loader.Factory accountLoaderFactory,
|
||||
AccountCache accountCache) {
|
||||
AccountInfo.Loader.Factory accountLoaderFactory) {
|
||||
super(groupCache, groupDetailFactory, accountLoaderFactory);
|
||||
this.groupCache = groupCache;
|
||||
}
|
||||
|
||||
void display(PrintWriter writer) throws UnloggedFailure, OrmException {
|
||||
void display(PrintWriter writer) throws OrmException {
|
||||
AccountGroup group = groupCache.get(new AccountGroup.NameKey(name));
|
||||
String errorText = "Group not found or not visible\n";
|
||||
|
||||
@@ -80,33 +77,28 @@ public class ListMembersCommand extends SshCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
List<AccountInfo> members = apply(group.getGroupUUID());
|
||||
ColumnFormatter formatter = new ColumnFormatter(writer, '\t');
|
||||
formatter.addColumn("id");
|
||||
formatter.addColumn("username");
|
||||
formatter.addColumn("full name");
|
||||
formatter.addColumn("email");
|
||||
formatter.nextLine();
|
||||
for (AccountInfo member : members) {
|
||||
if (member == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
formatter.addColumn(member._id.toString());
|
||||
formatter.addColumn(MoreObjects.firstNonNull(
|
||||
member.username, "n/a"));
|
||||
formatter.addColumn(MoreObjects.firstNonNull(
|
||||
Strings.emptyToNull(member.name), "n/a"));
|
||||
formatter.addColumn(MoreObjects.firstNonNull(member.email, "n/a"));
|
||||
formatter.nextLine();
|
||||
List<AccountInfo> members = apply(group.getGroupUUID());
|
||||
ColumnFormatter formatter = new ColumnFormatter(writer, '\t');
|
||||
formatter.addColumn("id");
|
||||
formatter.addColumn("username");
|
||||
formatter.addColumn("full name");
|
||||
formatter.addColumn("email");
|
||||
formatter.nextLine();
|
||||
for (AccountInfo member : members) {
|
||||
if (member == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
formatter.finish();
|
||||
} catch (MethodNotAllowedException e) {
|
||||
writer.write(errorText);
|
||||
writer.flush();
|
||||
formatter.addColumn(member._id.toString());
|
||||
formatter.addColumn(MoreObjects.firstNonNull(
|
||||
member.username, "n/a"));
|
||||
formatter.addColumn(MoreObjects.firstNonNull(
|
||||
Strings.emptyToNull(member.name), "n/a"));
|
||||
formatter.addColumn(MoreObjects.firstNonNull(member.email, "n/a"));
|
||||
formatter.nextLine();
|
||||
}
|
||||
|
||||
formatter.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user