Merge changes from topic 'coverity_scan'

* changes:
  Extract ChangeModifiedException out of PatchSetInserter to its own file
  Use StringBuilder instead of concatenation in SshLog
  Use StringBuilder instead of concatenation in ReviewCommand
This commit is contained in:
Shawn Pearce
2015-02-05 04:01:33 +00:00
committed by Gerrit Code Review
4 changed files with 32 additions and 15 deletions

View File

@@ -43,6 +43,7 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.notedb.ReviewerState;
import com.google.gerrit.server.patch.PatchSetInfoFactory;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.ChangeModifiedException;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.ssh.NoSshInfo;
@@ -380,12 +381,4 @@ public class PatchSetInserter {
return changeMessage != null && changeMessage.getKey().getParentKey()
.equals(patchSet.getId().getParentKey());
}
public class ChangeModifiedException extends InvalidChangeOperationException {
private static final long serialVersionUID = 1L;
public ChangeModifiedException(String msg) {
super(msg);
}
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.project;
public class ChangeModifiedException extends InvalidChangeOperationException {
private static final long serialVersionUID = 1L;
public ChangeModifiedException(String msg) {
super(msg);
}
}

View File

@@ -268,11 +268,11 @@ class SshLog implements LifecycleListener {
}
private String extractWhat(DispatchCommand dcmd) {
String commandName = dcmd.getCommandName();
StringBuilder commandName = new StringBuilder(dcmd.getCommandName());
String[] args = dcmd.getArguments();
for (int i = 1; i < args.length; i++) {
commandName = commandName + "." + args[i];
commandName.append(".").append(args[i]);
}
return commandName;
return commandName.toString();
}
}

View File

@@ -340,15 +340,16 @@ public class ReviewCommand extends SshCommand {
}
for (LabelType type : allProjectsControl.getLabelTypes().getLabelTypes()) {
String usage;
usage = "score for " + type.getName() + "\n";
StringBuilder usage = new StringBuilder("score for ")
.append(type.getName())
.append("\n");
for (LabelValue v : type.getValues()) {
usage += v.format() + "\n";
usage.append(v.format()).append("\n");
}
final String name = "--" + type.getName().toLowerCase();
optionList.add(new ApproveOption(name, usage, type));
optionList.add(new ApproveOption(name, usage.toString(), type));
}
super.parseCommandLine();