Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Code inspection: String concatenation in loop #2234

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/spoon/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,17 @@ protected static JSAP defineArgs() {
// Sets output type generation
opt2 = new FlaggedOption("output-type");
opt2.setLongFlag(opt2.getID());
String msg = "States how to print the processed source code: ";
StringBuilder msg = new StringBuilder("States how to print the processed source code: ");
int i = 0;
for (OutputType v : OutputType.values()) {
i++;
msg += v.toString();
msg.append(v.toString());
if (i != OutputType.values().length) {
msg += "|";
msg.append("|");
}
}
opt2.setStringParser(JSAP.STRING_PARSER);
opt2.setHelp(msg);
opt2.setHelp(msg.toString());
opt2.setDefault("classes");
jsap.registerParameter(opt2);

Expand Down Expand Up @@ -373,8 +373,8 @@ protected static JSAP defineArgs() {
opt2.setLongFlag(opt2.getID());
String acceptedValues = StringUtils.join(CLASSPATH_MODE.values(), "; ");
opt2.setStringParser(EnumeratedStringParser.getParser(acceptedValues));
msg = "Classpath mode to use in Spoon: " + acceptedValues;
opt2.setHelp(msg);
msg = new StringBuilder("Classpath mode to use in Spoon: " + acceptedValues);
opt2.setHelp(msg.toString());
opt2.setRequired(true);
opt2.setDefault(CLASSPATH_MODE.NOCLASSPATH.name());
jsap.registerParameter(opt2);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/spoon/refactoring/Refactoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ public <T> void visitCtExecutableReference(CtExecutableReference<T> reference) {
/** See doc in {@link CtType#copyType()} */
public static CtType<?> copyType(final CtType<?> type) {
CtType<?> clone = type.clone();
String tentativeTypeName = type.getSimpleName() + "Copy";
StringBuilder tentativeTypeName = new StringBuilder(type.getSimpleName() + "Copy");
while (type.getFactory().Type().get(type.getPackage().getQualifiedName() + "." + tentativeTypeName) != null) {
tentativeTypeName += "X";
tentativeTypeName.append("X");
}
final String cloneTypeName = tentativeTypeName;
final String cloneTypeName = tentativeTypeName.toString();
clone.setSimpleName(cloneTypeName);
type.getPackage().addType(clone);
new CtScanner() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ static String computeAnonymousName(char[] anonymousQualifiedName) {
* @return Qualified name.
*/
static String createQualifiedTypeName(char[][] typeName) {
String s = "";
StringBuilder s = new StringBuilder();
for (int i = 0; i < typeName.length - 1; i++) {
s += CharOperation.charToString(typeName[i]) + ".";
s.append(CharOperation.charToString(typeName[i])).append(".");
}
s += CharOperation.charToString(typeName[typeName.length - 1]);
return s;
s.append(CharOperation.charToString(typeName[typeName.length - 1]));
return s.toString();
}

/**
Expand Down