Add missing whitespace around keywords, operators and braces

Change-Id: I47923156c25c36d1755765f06e81bb6cdad6fe03
This commit is contained in:
David Pursehouse
2016-04-11 19:43:20 +09:00
parent b50cd86eff
commit c5ccbf196f
86 changed files with 125 additions and 120 deletions

View File

@@ -29,15 +29,15 @@ public class UseGerritConfigAnnotationTest extends AbstractDaemonTest {
Config serverConfig;
@Test
@GerritConfig(name="x.y", value="z")
@GerritConfig(name = "x.y", value = "z")
public void testOne() {
assertThat(serverConfig.getString("x", null, "y")).isEqualTo("z");
}
@Test
@GerritConfigs({
@GerritConfig(name="x.y", value="z"),
@GerritConfig(name="a.b", value="c")
@GerritConfig(name = "x.y", value = "z"),
@GerritConfig(name = "a.b", value = "c")
})
public void testMultiple() {
assertThat(serverConfig.getString("x", null, "y")).isEqualTo("z");

View File

@@ -103,7 +103,7 @@ public class ConfigChangeIT extends AbstractDaemonTest {
assertThat(e).hasMessage(
"Failed to submit 1 change due to the following problems:\n"
+ "Change " + n + ": Change contains a project configuration that"
+" changes the parent project.\n"
+ " changes the parent project.\n"
+ "The change must be submitted by a Gerrit administrator.");
}

View File

@@ -490,7 +490,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements
private void touch(SqlHandle c, K key) throws SQLException {
if (c.touch == null) {
c.touch =c.conn.prepareStatement("UPDATE data SET accessed=? WHERE k=?");
c.touch = c.conn.prepareStatement("UPDATE data SET accessed=? WHERE k=?");
}
try {
c.touch.setTimestamp(1, TimeUtil.nowTs());

View File

@@ -18,7 +18,7 @@ import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.extensions.common.WebLinkInfo;
@ExtensionPoint
public interface PatchSetWebLink extends WebLink{
public interface PatchSetWebLink extends WebLink {
/**
* {@link com.google.gerrit.extensions.common.WebLinkInfo}

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.rpc;
import com.google.gwt.user.client.rpc.AsyncCallback;
/** Transforms a value and passes it on to another callback. */
public abstract class TransformCallback<I, O> implements AsyncCallback<I>{
public abstract class TransformCallback<I, O> implements AsyncCallback<I> {
private final AsyncCallback<O> callback;
protected TransformCallback(AsyncCallback<O> callback) {

View File

@@ -424,7 +424,7 @@ public class Dispatcher {
int line = 0;
int at = rest.lastIndexOf('@');
if (at > 0) {
String l = rest.substring(at+1);
String l = rest.substring(at + 1);
if (l.startsWith("a")) {
side = DisplaySide.A;
l = l.substring(1);

View File

@@ -936,7 +936,7 @@ public class Gerrit implements EntryPoint {
@Override
public void onKeyDown(KeyDownEvent event) {
if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
showHidePopup();
event.preventDefault();
}

View File

@@ -81,7 +81,7 @@ public abstract class SettingsScreen extends MenuScreen {
private void linkByPlugin(String pluginName, String text, String target) {
if (ambiguousMenuNames.contains(text)) {
text += " ("+ pluginName + ")";
text += " (" + pluginName + ")";
}
link(text, target);
}

View File

@@ -211,7 +211,9 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
protected void display(final GroupInfo group, final boolean canModify) {
groupUUIDLabel.setText(group.getGroupUUID().get());
groupNameTxt.setText(group.name());
ownerTxt.setText(group.owner() != null?group.owner():Util.M.deletedReference(group.getOwnerUUID().get()));
ownerTxt.setText(group.owner() != null
? group.owner()
: Util.M.deletedReference(group.getOwnerUUID().get()));
descTxt.setText(group.description());
visibleToAllCheckBox.setValue(group.options().isVisibleToAll());
setMembersTabVisible(AccountGroup.isInternalGroup(group.getGroupUUID()));

View File

@@ -47,7 +47,7 @@ public class GroupReferenceBox extends Composite implements
toValue(event.getSelectedItem()));
}
});
suggestBox.addCloseHandler(new CloseHandler<RemoteSuggestBox>(){
suggestBox.addCloseHandler(new CloseHandler<RemoteSuggestBox>() {
@Override
public void onClose(CloseEvent<RemoteSuggestBox> event) {
suggestBox.setText("");

View File

@@ -113,7 +113,7 @@ public class GroupTable extends NavigationTable<GroupInfo> {
return a.name().compareTo(b.name());
}
});
for(GroupInfo group : list.subList(fromIndex, toIndex)) {
for (GroupInfo group : list.subList(fromIndex, toIndex)) {
final int row = table.getRowCount();
table.insertRow(row);
applyDataRowStyle(row);

View File

@@ -183,7 +183,7 @@ public class ProjectAccessScreen extends ProjectScreen {
driver.edit(mock);
}
@UiHandler(value={"cancel1", "cancel2"})
@UiHandler(value = {"cancel1", "cancel2"})
void onCancel(@SuppressWarnings("unused") ClickEvent event) {
Gerrit.display(PageLinks.toProjectAcceess(getProjectKey()));
}

View File

@@ -132,7 +132,7 @@ public class Hashtags extends Composite {
ClickEvent.getType());
}
void init(ChangeScreen.Style style){
void init(ChangeScreen.Style style) {
this.style = style;
}
@@ -246,12 +246,12 @@ public class Hashtags extends Composite {
input.init(toJsArrayString(add), toJsArrayString(remove));
return input;
}
private static JsArrayString toJsArrayString(String commaSeparated){
private static JsArrayString toJsArrayString(String commaSeparated) {
if (commaSeparated == null || commaSeparated.equals("")) {
return null;
}
JsArrayString array = JsArrayString.createArray().cast();
for (String hashtag : commaSeparated.split(",")){
for (String hashtag : commaSeparated.split(",")) {
array.push(hashtag.trim());
}
return array;

View File

@@ -57,14 +57,14 @@ class LineComment extends Composite {
ps = defaultPs;
psLoc.removeFromParent();
psLoc = null;
psNum= null;
psNum = null;
} else {
ps = defaultPs;
sideLoc.removeFromParent();
sideLoc = null;
psLoc.removeFromParent();
psLoc = null;
psNum= null;
psNum = null;
}
if (info.hasLine()) {

View File

@@ -170,7 +170,7 @@ public class ChangeApi {
public static RestApi hashtags(int changeId) {
return change(changeId).view("hashtags");
}
public static RestApi hashtag(int changeId, String hashtag){
public static RestApi hashtag(int changeId, String hashtag) {
return change(changeId).view("hashtags").id(hashtag);
}

View File

@@ -493,7 +493,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
if (titleText != null) {
setTitleText(titleText);
return true;
} else if(titleWidget != null) {
} else if (titleWidget != null) {
setTitleWidget(titleWidget);
return true;
}

View File

@@ -84,7 +84,7 @@ public class DashboardsTable extends NavigationTable<DashboardInfo> {
});
String ref = null;
for(DashboardInfo d : list) {
for (DashboardInfo d : list) {
if (!d.ref().equals(ref)) {
ref = d.ref();
insertTitleRow(table.getRowCount(), ref);

View File

@@ -44,9 +44,9 @@ class SideBySideSkipBar extends SkipBar {
String noExpand();
}
@UiField(provided=true) Anchor skipNum;
@UiField(provided=true) Anchor upArrow;
@UiField(provided=true) Anchor downArrow;
@UiField(provided = true) Anchor skipNum;
@UiField(provided = true) Anchor upArrow;
@UiField(provided = true) Anchor downArrow;
@UiField SkipBarStyle style;
private final SideBySideSkipManager manager;

View File

@@ -44,9 +44,9 @@ class UnifiedSkipBar extends SkipBar {
String noExpand();
}
@UiField(provided=true) Anchor skipNum;
@UiField(provided=true) Anchor upArrow;
@UiField(provided=true) Anchor downArrow;
@UiField(provided = true) Anchor skipNum;
@UiField(provided = true) Anchor upArrow;
@UiField(provided = true) Anchor downArrow;
@UiField SkipBarStyle style;
private final UnifiedSkipManager manager;

View File

@@ -81,7 +81,7 @@ public class MorphingTabPanel extends TabPanel {
/* Re-insert the widget right after the first visible widget found
when scanning backwards from the current widget */
for (int pos = origPos -1; pos >=0 ; pos--) {
for (int pos = origPos - 1; pos >= 0 ; pos--) {
int visiblePos = visibles.indexOf(widgets.get(pos));
if (visiblePos != -1) {
visibles.add(visiblePos + 1, w);

View File

@@ -36,7 +36,7 @@ public class ScreenLoadEvent extends GwtEvent<ScreenLoadHandler> {
return TYPE;
}
public Screen getScreen(){
public Screen getScreen() {
return screen;
}
}

View File

@@ -60,7 +60,7 @@ public class GitOverHttpModule extends ServletModule {
filter("/a/*").through(authFilter);
}
private boolean isHttpEnabled(){
private boolean isHttpEnabled() {
return downloadConfig.getDownloadSchemes().contains(CoreDownloadSchemes.ANON_HTTP)
|| downloadConfig.getDownloadSchemes().contains(CoreDownloadSchemes.HTTP);
}

View File

@@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest;
public class LoginUrlToken {
private static final String DEFAULT_TOKEN = '#' + PageLinks.MINE;
public static String getToken(final HttpServletRequest req){
public static String getToken(final HttpServletRequest req) {
String token = req.getPathInfo();
if (Strings.isNullOrEmpty(token)) {
return DEFAULT_TOKEN;

View File

@@ -221,7 +221,7 @@ class ProjectOAuthFilter implements Filter {
throw new ServletException("OAuth login provider configuration is"
+ " invalid: Must be of the form pluginName:providerName");
}
defaultAuthPlugin= gitOAuthProvider.substring(0, splitPos);
defaultAuthPlugin = gitOAuthProvider.substring(0, splitPos);
defaultAuthProvider = gitOAuthProvider.substring(splitPos + 1);
OAuthLoginProvider provider = loginProviders.get(defaultAuthPlugin,
defaultAuthProvider);

View File

@@ -157,7 +157,7 @@ class HttpAuthFilter implements Filter {
}
String getRemoteExternalIdToken(HttpServletRequest req) {
if(externalIdHeader != null) {
if (externalIdHeader != null) {
return emptyToNull(req.getHeader(externalIdHeader));
} else {
return null;

View File

@@ -125,7 +125,7 @@ class HttpPluginServlet extends HttpServlet
int c = host.lastIndexOf(':');
if (0 <= c) {
sshHost = host.substring(0, c);
sshPort = Integer.parseInt(host.substring(c+1));
sshPort = Integer.parseInt(host.substring(c + 1));
} else {
sshHost = host;
sshPort = 22;
@@ -346,7 +346,7 @@ class HttpPluginServlet extends HttpServlet
int nameOffset) throws IOException {
if (!entries.isEmpty()) {
md.append("## ").append(sectionTitle).append(" ##\n");
for(PluginEntry entry : entries) {
for (PluginEntry entry : entries) {
String rsrc = entry.getName().substring(prefix.length());
String entryTitle;
if (rsrc.endsWith(".html")) {

View File

@@ -19,7 +19,7 @@ import com.google.common.cache.Cache;
import java.nio.file.Path;
/** Serve a single static file, regardless of path. */
class SingleFileServlet extends ResourceServlet{
class SingleFileServlet extends ResourceServlet {
private static final long serialVersionUID = 1L;
private final Path path;

View File

@@ -796,7 +796,7 @@ public class RestApiServlet extends HttpServlet {
final BinaryResult src) throws IOException {
TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
buf.write(JSON_MAGIC);
try(Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
try (Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
JsonWriter json = new JsonWriter(w)) {
json.setLenient(true);
json.setHtmlSafe(true);

View File

@@ -74,7 +74,7 @@ class AccountServiceImpl extends BaseServiceImplementation implements
@Override
public void changeDiffPreferences(final DiffPreferencesInfo diffPref,
AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>(){
run(callback, new Action<VoidResult>() {
@Override
public VoidResult run(ReviewDb db) throws OrmException {
if (!getUser().isIdentifiedUser()) {

View File

@@ -143,7 +143,8 @@ final class WrappableSearcherManager extends ReferenceManager<IndexSearcher> {
@Override
protected IndexSearcher refreshIfNeeded(IndexSearcher referenceToRefresh) throws IOException {
final IndexReader r = referenceToRefresh.getIndexReader();
assert r instanceof DirectoryReader: "searcher's IndexReader should be a DirectoryReader, but got " + r;
assert r instanceof DirectoryReader :
"searcher's IndexReader should be a DirectoryReader, but got " + r;
final IndexReader newReader = DirectoryReader.openIfChanged((DirectoryReader) r);
if (newReader == null) {
return null;
@@ -171,7 +172,8 @@ final class WrappableSearcherManager extends ReferenceManager<IndexSearcher> {
final IndexSearcher searcher = acquire();
try {
final IndexReader r = searcher.getIndexReader();
assert r instanceof DirectoryReader: "searcher's IndexReader should be a DirectoryReader, but got " + r;
assert r instanceof DirectoryReader :
"searcher's IndexReader should be a DirectoryReader, but got " + r;
return ((DirectoryReader) r).isCurrent();
} finally {
release(searcher);

View File

@@ -218,7 +218,7 @@ class LoginForm extends HttpServlet {
url.append(r.providerUrl);
if (r.providerArgs != null && !r.providerArgs.isEmpty()) {
boolean first = true;
for(Map.Entry<String, String> arg : r.providerArgs.entrySet()) {
for (Map.Entry<String, String> arg : r.providerArgs.entrySet()) {
if (first) {
url.append('?');
first = false;

View File

@@ -165,7 +165,7 @@ public class AuthSMTPClient extends SMTPClient {
}
String cmd = encodeBase64(smtpUser.getBytes(UTF_8));
if(sendCommand(cmd) != 334) {
if (sendCommand(cmd) != 334) {
return false;
}

View File

@@ -116,7 +116,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
private class Worker extends Thread {
@Override
public void run() {
try (ReviewDb db = database.open()){
try (ReviewDb db = database.open()) {
for (;;) {
final AccountExternalId extId = next();
if (extId == null) {

View File

@@ -159,7 +159,7 @@ public class Reindex extends SiteProgram {
int n = result.doneCount() + result.failedCount();
double t = result.elapsed(TimeUnit.MILLISECONDS) / 1000d;
System.out.format("Reindexed %d documents in %s index in %.01fs (%.01f/s)\n",
n, def.getName(), t, n/t);
n, def.getName(), t, n / t);
if (result.success()) {
index.markReady(true);
}

View File

@@ -68,10 +68,11 @@ public class InitPlugins implements InitStep {
}
});
return FluentIterable.from(result).toSortedList(new Comparator<PluginData>() {
@Override
public int compare(PluginData a, PluginData b) {
return a.name.compareTo(b.name);
}});
@Override
public int compare(PluginData a, PluginData b) {
return a.name.compareTo(b.name);
}
});
}
private final ConsoleUI ui;

View File

@@ -180,7 +180,7 @@ public class AllProjectsConfig extends VersionedMetaData {
ru.setExpectedOldObjectId(revision);
ru.setRefLogMessage(refLogMsg, false);
RefUpdate.Result r = ru.update();
switch(r) {
switch (r) {
case FAST_FORWARD:
case NEW:
case NO_CHANGE:

View File

@@ -24,7 +24,7 @@ import com.google.gwtorm.client.StringKey;
public final class Project {
/** Project name key */
public static class NameKey extends
StringKey<com.google.gwtorm.client.Key<?>>{
StringKey<com.google.gwtorm.client.Key<?>> {
private static final long serialVersionUID = 1L;
@Column(id = 1)

View File

@@ -44,7 +44,7 @@ public class WebLinks {
@Override
public boolean apply(WebLinkInfo link) {
if (link == null){
if (link == null) {
return false;
} else if (Strings.isNullOrEmpty(link.name)
|| Strings.isNullOrEmpty(link.url)) {

View File

@@ -354,7 +354,7 @@ public class AccountManager {
}
try {
update(db, who, extId);
} catch(NameAlreadyUsedException | InvalidUserNameException e) {
} catch (NameAlreadyUsedException | InvalidUserNameException e) {
throw new AccountException("Account update failed", e);
}

View File

@@ -35,7 +35,7 @@ import com.google.inject.Singleton;
@Singleton
public class AccountsCollection implements
RestCollection<TopLevelResource, AccountResource>,
AcceptsCreate<TopLevelResource>{
AcceptsCreate<TopLevelResource> {
private final Provider<CurrentUser> self;
private final AccountResolver resolver;
private final AccountControl.Factory accountControlFactory;

View File

@@ -95,7 +95,7 @@ public class GroupCacheImpl implements GroupCache {
Optional<AccountGroup> g = byId.get(groupId);
return g.isPresent() ? g.get() : missing(groupId);
} catch (ExecutionException e) {
log.warn("Cannot load group "+groupId, e);
log.warn("Cannot load group " + groupId, e);
return missing(groupId);
}
}

View File

@@ -99,7 +99,7 @@ public class StarredChanges implements
@SuppressWarnings("unchecked")
@Override
public RestModifyView<AccountResource, EmptyInput> create(
AccountResource parent, IdString id) throws UnprocessableEntityException{
AccountResource parent, IdString id) throws UnprocessableEntityException {
try {
return createProvider.get()
.setChange(changes.parse(TopLevelResource.INSTANCE, id));

View File

@@ -403,7 +403,7 @@ public class ChangeEdits implements
rsrc.getChangeEdit(),
rsrc.getPath(),
input.content);
} catch(InvalidChangeOperationException | IOException e) {
} catch (InvalidChangeOperationException | IOException e) {
throw new ResourceConflictException(e.getMessage());
}
return Response.none();
@@ -434,7 +434,7 @@ public class ChangeEdits implements
throws AuthException, ResourceConflictException {
try {
editModifier.deleteFile(rsrc.getChangeEdit(), rsrc.getPath());
} catch(InvalidChangeOperationException | IOException e) {
} catch (InvalidChangeOperationException | IOException e) {
throw new ResourceConflictException(e.getMessage());
}
return Response.none();

View File

@@ -406,7 +406,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
List<LabelType> labels = changeControl.getLabelTypes().getLabelTypes();
Map<String, Short> allApprovals = new HashMap<>();
Map<String, Short> oldApprovals = new HashMap<>();
for (LabelType lt : labels){
for (LabelType lt : labels) {
allApprovals.put(lt.getName(), (short) 0);
oldApprovals.put(lt.getName(), null);
}

View File

@@ -288,8 +288,8 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
public static class ChangeKindWeigher implements Weigher<Key, ChangeKind> {
@Override
public int weigh(Key key, ChangeKind changeKind) {
return 16 + 2*36 + 2*key.strategyName.length() // Size of Key, 64 bit JVM
+ 2*changeKind.name().length(); // Size of ChangeKind, 64 bit JVM
return 16 + 2 * 36 + 2 * key.strategyName.length() // Size of Key, 64 bit JVM
+ 2 * changeKind.name().length(); // Size of ChangeKind, 64 bit JVM
}
}

View File

@@ -164,8 +164,8 @@ public class GetDiff implements RestReadView<FileResource> {
case INSERT:
case REPLACE:
List<Edit> internalEdit = edit instanceof ReplaceEdit
? ((ReplaceEdit) edit).getInternalEdits()
: null;
? ((ReplaceEdit) edit).getInternalEdits()
: null;
content.addDiff(edit.getEndA(), edit.getEndB(), internalEdit);
break;
case EMPTY:

View File

@@ -147,7 +147,7 @@ public class ChangeEditUtil {
int n = change.currentPatchSetId().get();
String[] refNames = new String[n];
for (int i = n; i > 0; i--) {
refNames[i-1] = RefNames.refsEdit(
refNames[i - 1] = RefNames.refsEdit(
u.getAccountId(), change.getId(),
new PatchSet.Id(change.getId(), i));
}

View File

@@ -244,7 +244,7 @@ public class EventFactory {
SubmitLabelAttribute la = new SubmitLabelAttribute();
la.label = lbl.label;
la.status = lbl.status.name();
if(lbl.appliedBy != null) {
if (lbl.appliedBy != null) {
Account a = accountCache.get(lbl.appliedBy).getAccount();
la.by = asAccountAttribute(a);
}

View File

@@ -53,7 +53,7 @@ public class DestinationList extends TabFile {
protected static Set<Branch.NameKey> toSet(List<Row> destRows) {
Set<Branch.NameKey> dests = Sets.newHashSetWithExpectedSize(destRows.size());
for(Row row : destRows) {
for (Row row : destRows) {
dests.add(new Branch.NameKey(new Project.NameKey(row.right), row.left));
}
return dests;

View File

@@ -39,7 +39,7 @@ public class GroupList extends TabFile {
List<Row> rows = parse(text, FILE_NAME, TRIM, TRIM, errors);
Map<AccountGroup.UUID, GroupReference> groupsByUUID =
new HashMap<>(rows.size());
for(Row row : rows) {
for (Row row : rows) {
AccountGroup.UUID uuid = new AccountGroup.UUID(row.left);
String name = row.right;
GroupReference ref = new GroupReference(uuid, name);

View File

@@ -362,7 +362,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager,
final String name = nameKey.get();
return name.length() == 0 // no empty paths
|| name.charAt(name.length() -1) == '/' // no suffix
|| name.charAt(name.length() - 1) == '/' // no suffix
|| name.indexOf('\\') >= 0 // no windows/dos style paths
|| name.charAt(0) == '/' // no absolute paths
|| new File(name).isAbsolute() // no absolute paths

View File

@@ -380,7 +380,7 @@ public class ReplaceOp extends BatchUpdate.Op {
hooks.doChangeMergedHook(change, account, newPatchSet, ctx.getDb(),
commit.getName());
}
try{
try {
runHook(ctx);
} catch (Exception e) {
log.warn("ChangeHook.doCommentAddedHook delivery failed", e);
@@ -403,7 +403,7 @@ public class ReplaceOp extends BatchUpdate.Op {
List<LabelType> labels = changeControl.getLabelTypes().getLabelTypes();
Map<String, Short> allApprovals = new HashMap<>();
Map<String, Short> oldApprovals = new HashMap<>();
for (LabelType lt : labels){
for (LabelType lt : labels) {
allApprovals.put(lt.getName(), (short) 0);
oldApprovals.put(lt.getName(), null);
}

View File

@@ -147,7 +147,7 @@ public class SubmoduleOp {
ret.addAll(m.subscribedTo(branch));
}
}
logDebug("Calculated superprojects for " + branch + " are "+ ret);
logDebug("Calculated superprojects for " + branch + " are " + ret);
return ret;
}

View File

@@ -69,7 +69,7 @@ public class GroupsCollection implements
final CurrentUser user = self.get();
if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if(!(user.isIdentifiedUser())) {
} else if (!(user.isIdentifiedUser())) {
throw new ResourceNotFoundException();
}
@@ -82,7 +82,7 @@ public class GroupsCollection implements
final CurrentUser user = self.get();
if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if(!(user.isIdentifiedUser())) {
} else if (!(user.isIdentifiedUser())) {
throw new ResourceNotFoundException(id);
}

View File

@@ -303,7 +303,7 @@ public abstract class OutgoingEmail {
} else if (email != null) {
return email;
} else /* (name == null && email == null) */{
} else /* (name == null && email == null) */ {
return args.anonymousCowardName + " #" + accountId;
}
}

View File

@@ -159,10 +159,10 @@ public class SmtpEmailSender implements EmailSender {
setMissingHeader(hdrs, "Content-Transfer-Encoding", "8bit");
setMissingHeader(hdrs, "Content-Disposition", "inline");
setMissingHeader(hdrs, "User-Agent", "Gerrit/" + Version.getVersion());
if(importance != null) {
if (importance != null) {
setMissingHeader(hdrs, "Importance", importance);
}
if(expiryDays > 0) {
if (expiryDays > 0) {
Date expiry = new Date(TimeUtil.nowMs() +
expiryDays * 24 * 60 * 60 * 1000L );
setMissingHeader(hdrs, "Expiry-Date",

View File

@@ -369,7 +369,7 @@ public class ChangeNoteUtil {
int commentLength =
RawParseUtils.parseBase10(note, startOfLength, i);
int endOfLine = RawParseUtils.nextLF(note, curr.value);
if (i.value != endOfLine-1) {
if (i.value != endOfLine - 1) {
throw parseException(changeId, "could not parse %s", PATCH_SET);
}
curr.value = endOfLine;

View File

@@ -479,7 +479,7 @@ class ChangeNotesParser implements AutoCloseable {
int ptr = size - 1;
int changeMessageEnd = -1;
while(ptr > changeMessageStart) {
while (ptr > changeMessageStart) {
ptr = RawParseUtils.prevLF(raw, ptr, '\r');
if (ptr == -1) {
break;

View File

@@ -21,8 +21,8 @@ public class IntraLineWeigher implements
Weigher<IntraLineDiffKey, IntraLineDiff> {
@Override
public int weigh(IntraLineDiffKey key, IntraLineDiff value) {
return 16 + 8*8 + 2*36 // Size of IntraLineDiffKey, 64 bit JVM
+ 16 + 2*8 + 16+8+4+20 // Size of IntraLineDiff, 64 bit JVM
+ (8 + 16 + 4*4) * value.getEdits().size();
return 16 + 8 * 8 + 2 * 36 // Size of IntraLineDiffKey, 64 bit JVM
+ 16 + 2 * 8 + 16 + 8 + 4 + 20 // Size of IntraLineDiff, 64 bit JVM
+ (8 + 16 + 4 * 4) * value.getEdits().size();
}
}

View File

@@ -130,17 +130,17 @@ public class PatchListEntry {
}
int weigh() {
int size = 16 + 6*8 + 2*4 + 20 + 16+8+4+20;
int size = 16 + 6 * 8 + 2 * 4 + 20 + 16 + 8 + 4 + 20;
size += stringSize(oldName);
size += stringSize(newName);
size += header.length;
size += (8 + 16 + 4*4) * edits.size();
size += (8 + 16 + 4 * 4) * edits.size();
return size;
}
private static int stringSize(String str) {
if (str != null) {
return 16 + 3*4 + 16 + str.length() * 2;
return 16 + 3 * 4 + 16 + str.length() * 2;
}
return 0;
}

View File

@@ -20,8 +20,8 @@ import com.google.common.cache.Weigher;
public class PatchListWeigher implements Weigher<PatchListKey, PatchList> {
@Override
public int weigh(PatchListKey key, PatchList value) {
int size = 16 + 4*8 + 2*36 // Size of PatchListKey, 64 bit JVM
+ 16 + 3*8 + 3*4 + 20; // Size of PatchList, 64 bit JVM
int size = 16 + 4 * 8 + 2 * 36 // Size of PatchListKey, 64 bit JVM
+ 16 + 3 * 8 + 3 * 4 + 20; // Size of PatchList, 64 bit JVM
for (PatchListEntry e : value.getPatches()) {
size += e.weigh();
}

View File

@@ -472,7 +472,7 @@ public class PluginGuiceEnvironment {
private static <T> void replace(Plugin newPlugin,
ReloadableRegistrationHandle<T> h, Binding<T> b) {
RegistrationHandle n = h.replace(b.getKey(), b.getProvider());
if (n != null){
if (n != null) {
newPlugin.add(n);
}
}

View File

@@ -623,7 +623,7 @@ public class PluginLoader implements LifecycleListener {
for (String name : pluginPaths.keys()) {
for (Path pluginPath : pluginPaths.asMap().get(name)) {
if (!pluginPath.getFileName().toString().endsWith(".disabled")) {
assert(!activePlugins.containsKey(name));
assert !activePlugins.containsKey(name);
activePlugins.put(name, pluginPath);
}
}
@@ -656,7 +656,7 @@ public class PluginLoader implements LifecycleListener {
continue;
}
Path winner = Iterables.getFirst(enabled, null);
assert(winner != null);
assert winner != null;
// Disable all loser plugins by renaming their file names to
// "file.disabled" and replace the disabled files in the multimap.
Collection<Path> elementsToRemove = Lists.newArrayList();

View File

@@ -100,7 +100,7 @@ public class ServerPlugin extends Plugin {
this.sysModule = load(sysName, classLoader);
this.sshModule = load(sshName, classLoader);
this.httpModule = load(httpName, classLoader);
} catch(ClassNotFoundException e) {
} catch (ClassNotFoundException e) {
throw new InvalidPluginException("Unable to load plugin Guice Modules", e);
}
}

View File

@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
@Singleton
public class DeleteBranch implements RestModifyView<BranchResource, Input>{
public class DeleteBranch implements RestModifyView<BranchResource, Input> {
private static final Logger log = LoggerFactory.getLogger(DeleteBranch.class);
private static final int MAX_LOCK_FAILURE_CALLS = 10;
private static final long SLEEP_ON_LOCK_FAILURE_MS = 15;

View File

@@ -90,7 +90,7 @@ public class SetHead implements RestModifyView<ProjectResource, Input> {
final RefUpdate u = repo.updateRef(Constants.HEAD, true);
u.setRefLogIdent(identifiedUser.get().newRefLogIdent());
RefUpdate.Result res = u.link(newHead);
switch(res) {
switch (res) {
case NO_CHANGE:
case RENAMED:
case FORCED:

View File

@@ -154,7 +154,7 @@ public class Schema_115 extends SchemaVersion {
RevWalk rw = new RevWalk(git)) {
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
for (Map.Entry<Account.Id, DiffPreferencesInfo> e : imports.entrySet()) {
try(MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
try (MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
allUsersName, git, bru)) {
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);

View File

@@ -149,7 +149,7 @@ public class Schema_119 extends SchemaVersion {
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
for (Map.Entry<Account.Id, GeneralPreferencesInfo> e
: imports.entrySet()) {
try(MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
try (MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
allUsersName, git, bru)) {
md.getCommitBuilder().setAuthor(serverUser);
md.getCommitBuilder().setCommitter(serverUser);

View File

@@ -55,7 +55,7 @@ public class Schema_120 extends SchemaVersion {
try (Repository git = mgr.openRepository(subbranch.getParentKey());
RevWalk rw = new RevWalk(git)) {
BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
try(MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
try (MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED,
subbranch.getParentKey(), git, bru)) {
md.setMessage("Added superproject subscription during upgrade");
ProjectConfig pc = ProjectConfig.read(md);

View File

@@ -67,7 +67,7 @@ public final class MostSpecificComparator implements
cmp = -1;
} else if (!p1_finite && p2_finite) {
cmp = 1;
} else /* if (f1 == f2) */{
} else /* if (f1 == f2) */ {
cmp = 0;
}
}

View File

@@ -48,13 +48,13 @@ public class PRED_commit_stats_3 extends Predicate.P3 {
Term a3 = arg3.dereference();
PatchList pl = StoredValues.PATCH_LIST.get(engine);
if(!a1.unify(new IntegerTerm(pl.getPatches().size() -1),engine.trail)) { //Account for /COMMIT_MSG.
if (!a1.unify(new IntegerTerm(pl.getPatches().size() - 1),engine.trail)) { //Account for /COMMIT_MSG.
return engine.fail();
}
if(!a2.unify(new IntegerTerm(pl.getInsertions()),engine.trail)) {
if (!a2.unify(new IntegerTerm(pl.getInsertions()),engine.trail)) {
return engine.fail();
}
if(!a3.unify(new IntegerTerm(pl.getDeletions()),engine.trail)) {
if (!a3.unify(new IntegerTerm(pl.getDeletions()),engine.trail)) {
return engine.fail();
}
return cont;

View File

@@ -26,14 +26,14 @@ public class GitwebConfigTest {
@Test
public void testValidPathSeparator() {
for(char c : VALID_CHARACTERS.toCharArray()) {
for (char c : VALID_CHARACTERS.toCharArray()) {
assertTrue("valid character rejected: " + c, GitwebConfig.isValidPathSeparator(c));
}
}
@Test
public void testInalidPathSeparator() {
for(char c : SOME_INVALID_CHARACTERS.toCharArray()) {
for (char c : SOME_INVALID_CHARACTERS.toCharArray()) {
assertFalse("invalid character accepted: " + c, GitwebConfig.isValidPathSeparator(c));
}
}

View File

@@ -214,7 +214,7 @@ public class LabelNormalizerTest {
}
private void save(ProjectConfig pc) throws Exception {
try(MetaDataUpdate md =
try (MetaDataUpdate md =
metaDataUpdateFactory.create(pc.getProject().getNameKey(), user)) {
pc.commit(md);
projectCache.evict(pc.getProject().getNameKey());

View File

@@ -135,7 +135,7 @@ public class ChangeBundleTest {
c2.setTopic("topic");
assertDiffs(b1, b2,
"topic differs for Change.Id "+ c1.getId() + ": {null} != {topic}");
"topic differs for Change.Id " + c1.getId() + ": {null} != {topic}");
}
@Test

View File

@@ -149,7 +149,7 @@ public class NoteDbChangeStateTest {
checkArgument(args.length % 2 == 0);
ImmutableMap.Builder<Account.Id, ObjectId> b = ImmutableMap.builder();
for (int i = 0; i < args.length / 2; i++) {
b.put((Account.Id) args[2*i], (ObjectId) args[2*i+1]);
b.put((Account.Id) args[2 * i], (ObjectId) args[2 * i + 1]);
}
return b.build();
}

View File

@@ -118,7 +118,7 @@ public abstract class FilesystemLoggingMockingTestCase extends LoggingMockingTes
* @throws IOException If a file could not be created.
*/
private File createTempFile(String suffix) throws IOException {
String prefix ="gerrit_test_";
String prefix = "gerrit_test_";
if (!Strings.isNullOrEmpty(getName())) {
prefix += getName() + "_";
}

View File

@@ -109,7 +109,7 @@ public abstract class LoggingMockingTestCase extends MockingTestCase {
// and we can improve later to allow tests to specify which loggers are
// to check.
loggerName = this.getClass().getCanonicalName();
loggerName = loggerName.substring(0, loggerName.length()-4);
loggerName = loggerName.substring(0, loggerName.length() - 4);
loggerSettings = LogUtil.logToCollection(loggerName, loggedEvents);
}

View File

@@ -489,21 +489,21 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
do {
bits = next(31);
val = bits % n;
} while (bits - val + (n-1) < 0);
} while (bits - val + (n - 1) < 0);
return val;
}
throw new IllegalArgumentException();
}
protected final int next(int numBits) {
int bytes = (numBits+7)/8;
int bytes = (numBits + 7) / 8;
byte[] next = new byte[bytes];
int ret = 0;
random.nextBytes(next);
for (int i = 0; i < bytes; i++) {
ret = (next[i] & 0xFF) | (ret << 8);
}
return ret >>> (bytes*8 - numBits);
return ret >>> (bytes * 8 - numBits);
}
}
@@ -674,7 +674,7 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
try {
kerberosPrincipal = "host/" +
InetAddress.getLocalHost().getCanonicalHostName();
} catch(UnknownHostException e) {
} catch (UnknownHostException e) {
kerberosPrincipal = "host/localhost";
}
}

View File

@@ -36,7 +36,7 @@ final class AproposCommand extends SshCommand {
@Inject
@CanonicalWebUrl String url;
@Argument(index=0, required = true, metaVar = "QUERY")
@Argument(index = 0, required = true, metaVar = "QUERY")
private String q;
@Override

View File

@@ -300,7 +300,7 @@ public class ReviewCommand extends SshCommand {
applyReview(patchSet, review);
}
if (rebaseChange){
if (rebaseChange) {
revisionApi(patchSet).rebase();
}

View File

@@ -198,7 +198,7 @@ final class ScpCommand extends BaseCommand {
private void header(final Entry dir, final int len) throws IOException,
UnsupportedEncodingException {
final StringBuilder buf = new StringBuilder();
switch(dir.getType()){
switch (dir.getType()) {
case DIR:
buf.append(TYPE_DIR);
break;

View File

@@ -125,7 +125,7 @@ final class ShowCaches extends SshCommand {
stdout.print('\n');
stdout.print(String.format(//
"%1s %-"+nw+"s|%-21s| %-5s |%-9s|\n" //
"%1s %-" + nw + "s|%-21s| %-5s |%-9s|\n" //
, "" //
, "Name" //
, "Entries" //
@@ -133,7 +133,7 @@ final class ShowCaches extends SshCommand {
, "Hit Ratio" //
));
stdout.print(String.format(//
"%1s %-"+nw+"s|%6s %6s %7s| %-5s |%-4s %-4s|\n" //
"%1s %-" + nw + "s|%6s %6s %7s| %-5s |%-4s %-4s|\n" //
, "" //
, "" //
, "Mem" //
@@ -209,7 +209,7 @@ final class ShowCaches extends SshCommand {
private void printCache(CacheInfo cache) {
stdout.print(String.format(
"%1s %-"+nw+"s|%6s %6s %7s| %7s |%4s %4s|\n",
"%1s %-" + nw + "s|%6s %6s %7s| %7s |%4s %4s|\n",
CacheType.DISK.equals(cache.type) ? "D" : "",
cache.name,
nullToEmpty(cache.entries.mem),

View File

@@ -127,7 +127,7 @@ public class UploadArchive extends AbstractGitCommand {
throw new Failure(1, "fatal: 'argument' token or flush expected");
}
String[] parts = s.substring(argCmd.length()).split("=", 2);
for(String p : parts) {
for (String p : parts) {
args.add(p);
}
}

View File

@@ -104,7 +104,7 @@ public class AsciiDoctor {
for (String attribute : attributes) {
int equalsIndex = attribute.indexOf('=');
if(equalsIndex > -1) {
if (equalsIndex > -1) {
String name = attribute.substring(0, equalsIndex);
String value = attribute.substring(equalsIndex + 1, attribute.length());