Eclipse: Warn on incomplete switch cases even when default exists
We already have the warning "Incomplete 'switch' cases on enum" enabled, but it does not warn when a case is missing if the switch has a default block. Enable the "Signal even if 'default' case exists" option. This would have enabled us to catch the problem that was fixed in Ied8ff0f8f. In most instances of the warning we can simply add the missing case(s) above the 'default', meaning there is no change in behaviour. However there are some instances where the missing case is a bug and should be handled correctly. These are fixed separately in follow-up commits. Change-Id: I3675d29981423043266a26b1a78932c5708a6272
This commit is contained in:
parent
82be744b7b
commit
0b7517a06e
@ -38,7 +38,7 @@ org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
|
@ -151,6 +151,7 @@ public class PageLinks {
|
||||
return "status:abandoned";
|
||||
case MERGED:
|
||||
return "status:merged";
|
||||
case DRAFT:
|
||||
case NEW:
|
||||
default:
|
||||
return "status:open";
|
||||
|
@ -139,6 +139,10 @@ public class PermissionRule implements Comparable<PermissionRule> {
|
||||
switch (a.getAction()) {
|
||||
case DENY:
|
||||
return 0;
|
||||
case ALLOW:
|
||||
case BATCH:
|
||||
case BLOCK:
|
||||
case INTERACTIVE:
|
||||
default:
|
||||
return 1 + a.getAction().ordinal();
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ public enum Theme {
|
||||
case NIGHT:
|
||||
case TWILIGHT:
|
||||
return true;
|
||||
case DEFAULT:
|
||||
case ECLIPSE:
|
||||
case ELEGANT:
|
||||
case NEAT:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -340,6 +340,13 @@ public class PublicKeyStore implements AutoCloseable {
|
||||
toAdd.clear();
|
||||
toRemove.clear();
|
||||
break;
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -80,6 +80,14 @@ public class DeleteGpgKey implements RestModifyView<GpgKey, Input> {
|
||||
case NO_CHANGE:
|
||||
case FAST_FORWARD:
|
||||
break;
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NEW:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new ResourceConflictException(
|
||||
"Failed to delete public key: " + saveResult);
|
||||
|
@ -232,6 +232,12 @@ public class PostGpgKeys implements RestModifyView<AccountResource, Input> {
|
||||
break;
|
||||
case NO_CHANGE:
|
||||
break;
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
// TODO(dborowitz): Backoff and retry on LOCK_FAILURE.
|
||||
throw new ResourceConflictException(
|
||||
|
@ -339,6 +339,13 @@ public class PublicKeyCheckerTest {
|
||||
case FAST_FORWARD:
|
||||
case FORCED:
|
||||
break;
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new AssertionError(result);
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ public class ProjectListScreen extends PaginatedProjectScreen {
|
||||
state.setTitle(Util.toLongString(k.state()));
|
||||
table.setWidget(row, ProjectsTable.C_STATE, state);
|
||||
break;
|
||||
case ACTIVE:
|
||||
default:
|
||||
// Intentionally left blank, do not show an icon when active.
|
||||
break;
|
||||
|
@ -1141,6 +1141,8 @@ public class ChangeScreen extends Screen {
|
||||
canSubmit = false;
|
||||
}
|
||||
break;
|
||||
case MAY:
|
||||
case OK:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -350,6 +350,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
|
||||
return accountInfo.username();
|
||||
case ABBREV:
|
||||
return getAbbreviation(accountInfo.name(), " ");
|
||||
case NONE:
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -391,6 +391,8 @@ public class SideBySide extends Screen {
|
||||
case OK:
|
||||
toggleShowIntraline();
|
||||
break;
|
||||
case FAILURE:
|
||||
case TIMEOUT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -253,6 +253,7 @@ public class UnifiedDiffTable extends AbstractPatchContentTable {
|
||||
case INSERT:
|
||||
n = Gerrit.RESOURCES.css().diffTextINSERT();
|
||||
break;
|
||||
case REPLACE:
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
@ -450,6 +450,7 @@ class OpenIdServiceImpl {
|
||||
case SIGN_IN:
|
||||
case REGISTER:
|
||||
return true;
|
||||
case LINK_IDENTIY:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -185,6 +185,13 @@ public class AllProjectsConfig extends VersionedMetaData {
|
||||
case NEW:
|
||||
case NO_CHANGE:
|
||||
break;
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new IOException("Failed to update " + getRefName() + " of "
|
||||
+ project + ": " + r.name());
|
||||
|
@ -99,6 +99,15 @@ public class StarredChangesUtil {
|
||||
switch (result) {
|
||||
case NEW:
|
||||
return;
|
||||
case FAST_FORWARD:
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new OrmException(
|
||||
String.format("Star change %d for account %d failed: %s",
|
||||
@ -138,6 +147,15 @@ public class StarredChangesUtil {
|
||||
switch (result) {
|
||||
case FORCED:
|
||||
return;
|
||||
case FAST_FORWARD:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NEW:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new OrmException(
|
||||
String.format("Unstar change %d for account %d failed: %s",
|
||||
|
@ -57,6 +57,8 @@ public class DefaultRealm extends AbstractRealm {
|
||||
switch (field) {
|
||||
case REGISTER_NEW_EMAIL:
|
||||
return authConfig.isAllowRegisterNewEmail();
|
||||
case FULL_NAME:
|
||||
case USER_NAME:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
@ -65,6 +65,13 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
case LDAP:
|
||||
accountId = createAccountByLdap(token);
|
||||
break;
|
||||
case CUSTOM_EXTENSION:
|
||||
case DEVELOPMENT_BECOME_ANY_ACCOUNT:
|
||||
case HTTP:
|
||||
case LDAP_BIND:
|
||||
case OAUTH:
|
||||
case OPENID:
|
||||
case OPENID_SSO:
|
||||
default:
|
||||
throw new CmdLineException(owner, "user \"" + token + "\" not found");
|
||||
}
|
||||
|
@ -562,6 +562,9 @@ public class ChangeJson {
|
||||
n.rejected = accountLoader.get(r.appliedBy);
|
||||
n.blocking = true;
|
||||
break;
|
||||
case IMPOSSIBLE:
|
||||
case MAY:
|
||||
case NEED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -558,6 +558,12 @@ public class ConsistencyChecker {
|
||||
p.status = Status.FIXED;
|
||||
p.outcome = "Repaired patch set ref";
|
||||
return;
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
p.status = Status.FIX_FAILED;
|
||||
p.outcome = "Failed to update patch set ref: " + result;
|
||||
|
@ -200,6 +200,8 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
||||
throw new ResourceConflictException(msg.getMessage());
|
||||
}
|
||||
//$FALL-THROUGH$
|
||||
case ABANDONED:
|
||||
case DRAFT:
|
||||
default:
|
||||
throw new ResourceConflictException("change is " + status(change));
|
||||
}
|
||||
|
@ -50,6 +50,10 @@ public class AuthModule extends AbstractModule {
|
||||
case CUSTOM_EXTENSION:
|
||||
break;
|
||||
|
||||
case DEVELOPMENT_BECOME_ANY_ACCOUNT:
|
||||
case HTTP:
|
||||
case OPENID:
|
||||
case OPENID_SSO:
|
||||
default:
|
||||
bind(Realm.class).to(DefaultRealm.class);
|
||||
DynamicSet.bind(binder(), AuthBackend.class).to(InternalAuthBackend.class);
|
||||
|
@ -327,6 +327,7 @@ public class ProjectConfigEntry {
|
||||
break;
|
||||
case LIST:
|
||||
case STRING:
|
||||
case ARRAY:
|
||||
default:
|
||||
configEntry.onUpdate(p, oldValue, newValue);
|
||||
}
|
||||
|
@ -287,6 +287,13 @@ public class ChangeEditUtil {
|
||||
case NEW:
|
||||
case NO_CHANGE:
|
||||
break;
|
||||
case FAST_FORWARD:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new IOException(String.format("Failed to delete ref %s: %s",
|
||||
refName, result));
|
||||
|
@ -1848,6 +1848,8 @@ public class ReceiveCommits {
|
||||
break;
|
||||
}
|
||||
//$FALL-THROUGH$
|
||||
case ABANDONED:
|
||||
case DRAFT:
|
||||
default:
|
||||
addMessage("change " + c.getChangeId() + " is "
|
||||
+ c.getStatus().name().toLowerCase());
|
||||
|
@ -335,7 +335,14 @@ public class SubmoduleOp {
|
||||
// TODO since this is performed "in the background" no mail will be
|
||||
// sent to inform users about the updated branch
|
||||
break;
|
||||
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new IOException(rfu.getResult().name());
|
||||
}
|
||||
|
@ -323,6 +323,15 @@ public abstract class VersionedMetaData {
|
||||
case FORCED:
|
||||
update.fireGitRefUpdatedEvent(ru);
|
||||
return;
|
||||
case FAST_FORWARD:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NEW:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new IOException("Cannot delete " + ru.getName() + " in "
|
||||
+ db.getDirectory() + ": " + ru.getResult());
|
||||
@ -391,6 +400,14 @@ public abstract class VersionedMetaData {
|
||||
revision = rw.parseCommit(ru.getNewObjectId());
|
||||
update.fireGitRefUpdatedEvent(ru);
|
||||
return revision;
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new IOException("Cannot update " + ru.getName() + " in "
|
||||
+ db.getDirectory() + ": " + ru.getResult());
|
||||
|
@ -159,6 +159,13 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_EXTENSION:
|
||||
case DEVELOPMENT_BECOME_ANY_ACCOUNT:
|
||||
case HTTP:
|
||||
case LDAP_BIND:
|
||||
case OAUTH:
|
||||
case OPENID:
|
||||
case OPENID_SSO:
|
||||
default:
|
||||
}
|
||||
throw e;
|
||||
|
@ -217,6 +217,13 @@ public class ChangeRebuilder {
|
||||
case NEW:
|
||||
case NO_CHANGE:
|
||||
break;
|
||||
case FAST_FORWARD:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default:
|
||||
throw new IOException(
|
||||
String.format("Failed to delete ref %s: %s", refName, result));
|
||||
|
@ -167,6 +167,12 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
|
||||
refPrefix = getRefPrefix(refPrefix);
|
||||
}
|
||||
//$FALL-THROUGH$
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default: {
|
||||
throw new IOException(result.name());
|
||||
}
|
||||
|
@ -368,6 +368,15 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
||||
case NEW:
|
||||
referenceUpdated.fire(project, ru, ReceiveCommand.Type.CREATE);
|
||||
break;
|
||||
case FAST_FORWARD:
|
||||
case FORCED:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case NO_CHANGE:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
case RENAMED:
|
||||
default: {
|
||||
throw new IOException(String.format(
|
||||
"Failed to create ref \"%s\": %s", ref, result.name()));
|
||||
|
@ -124,6 +124,11 @@ public class DeleteBranch implements RestModifyView<BranchResource, Input>{
|
||||
log.error("Cannot delete " + rsrc.getBranchKey() + ": " + result.name());
|
||||
throw new ResourceConflictException("cannot delete current branch");
|
||||
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case RENAMED:
|
||||
default:
|
||||
log.error("Cannot delete " + rsrc.getBranchKey() + ": " + result.name());
|
||||
throw new ResourceConflictException("cannot delete branch: " + result.name());
|
||||
|
@ -151,6 +151,13 @@ class DeleteBranches implements RestModifyView<ProjectResource, Input> {
|
||||
case REJECTED_OTHER_REASON:
|
||||
msg = format("Cannot delete %s: %s", cmd.getRefName(), cmd.getMessage());
|
||||
break;
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case OK:
|
||||
case REJECTED_MISSING_OBJECT:
|
||||
case REJECTED_NOCREATE:
|
||||
case REJECTED_NODELETE:
|
||||
case REJECTED_NONFASTFORWARD:
|
||||
default:
|
||||
msg = format("Cannot delete %s: %s", cmd.getRefName(), cmd.getResult());
|
||||
break;
|
||||
|
@ -264,6 +264,9 @@ public class RefControl {
|
||||
admin = getUser().getCapabilities().canAdministrateServer();
|
||||
break;
|
||||
|
||||
case GIT:
|
||||
case SSH_COMMAND:
|
||||
case WEB_BROWSER:
|
||||
default:
|
||||
owner = false;
|
||||
admin = false;
|
||||
@ -362,6 +365,11 @@ public class RefControl {
|
||||
case GIT:
|
||||
return canPushWithForce();
|
||||
|
||||
case JSON_RPC:
|
||||
case REST_API:
|
||||
case SSH_COMMAND:
|
||||
case UNKNOWN:
|
||||
case WEB_BROWSER:
|
||||
default:
|
||||
return getUser().getCapabilities().canAdministrateServer()
|
||||
|| (isOwner() && !isForceBlocked(Permission.PUSH))
|
||||
|
@ -96,6 +96,12 @@ public class SetHead implements RestModifyView<ProjectResource, Input> {
|
||||
case FORCED:
|
||||
case NEW:
|
||||
break;
|
||||
case FAST_FORWARD:
|
||||
case IO_FAILURE:
|
||||
case LOCK_FAILURE:
|
||||
case NOT_ATTEMPTED:
|
||||
case REJECTED:
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
default:
|
||||
throw new IOException("Setting HEAD failed with " + res);
|
||||
}
|
||||
|
@ -450,6 +450,7 @@ public class QueryShell {
|
||||
case JSON_SINGLE:
|
||||
collector.add(row);
|
||||
break;
|
||||
case PRETTY:
|
||||
default:
|
||||
final JsonObject obj = new JsonObject();
|
||||
obj.addProperty("type", "error");
|
||||
@ -482,6 +483,7 @@ public class QueryShell {
|
||||
}
|
||||
println(collector.toString());
|
||||
break;
|
||||
case PRETTY:
|
||||
default:
|
||||
final JsonObject obj = new JsonObject();
|
||||
obj.addProperty("type", "error");
|
||||
|
@ -88,6 +88,8 @@ final class ShowQueue extends SshCommand {
|
||||
case READY:
|
||||
start = format(task.state);
|
||||
break;
|
||||
case OTHER:
|
||||
case SLEEPING:
|
||||
default:
|
||||
start = time(now, task.delay);
|
||||
break;
|
||||
@ -147,6 +149,7 @@ final class ShowQueue extends SshCommand {
|
||||
return "waiting ....";
|
||||
case SLEEPING:
|
||||
return "sleeping";
|
||||
case OTHER:
|
||||
default:
|
||||
return state.toString();
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f4929df99e274113eb11a6bd6fe7a8b8f2088b6e
|
||||
Subproject commit e44cf6e191255c796f0316cdcc4280978bb4a4d2
|
Loading…
x
Reference in New Issue
Block a user