Skip to content

Commit 81af743

Browse files
hogejomkarg
authored andcommitted
Append newline character instead of string
1 parent 289f2f2 commit 81af743

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/main/java/com/beust/jcommander/DefaultUsageFormatter.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final void usage(String commandName, StringBuilder out, String indent) {
6767

6868
if (description != null) {
6969
out.append(indent).append(description);
70-
out.append("\n");
70+
out.append('\n');
7171
}
7272
jc.getUsageFormatter().usage(out, indent);
7373
}
@@ -154,7 +154,7 @@ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean hasCom
154154
mainLine.append(" ").append(commander.getMainParameter().getDescription().getDescription());
155155
}
156156
wrapDescription(out, indentCount, mainLine.toString());
157-
out.append("\n");
157+
out.append('\n');
158158
}
159159

160160
/**
@@ -169,7 +169,7 @@ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean hasCom
169169
public void appendAllParametersDetails(StringBuilder out, int indentCount, String indent,
170170
List<ParameterDescription> sortedParameters) {
171171
if (sortedParameters.size() > 0) {
172-
out.append("\n");
172+
out.append('\n');
173173
out.append(indent).append(" Options:\n");
174174
}
175175

@@ -183,7 +183,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin
183183
.append(" ")
184184
.append(parameter.required() ? "* " : " ")
185185
.append(pd.getNames())
186-
.append("\n");
186+
.append('\n');
187187

188188
if (hasDescription) {
189189
wrapDescription(out, indentCount, s(indentCount) + description);
@@ -242,7 +242,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin
242242
out.append(possibleValues);
243243
}
244244
}
245-
out.append("\n");
245+
out.append('\n');
246246
}
247247
}
248248

@@ -270,18 +270,18 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn
270270
if (hasOnlyHiddenCommands)
271271
return;
272272

273-
out.append("\n");
273+
out.append('\n');
274274
out.append(indent + " Commands:\n");
275275

276-
boolean firstCommand = true;
276+
var firstCommand = true;
277277
// The magic value 3 is the number of spaces between the name of the option and its description
278278
for (Map.Entry<JCommander.ProgramName, JCommander> commands : commander.getRawCommands().entrySet()) {
279279
Object arg = commands.getValue().getObjects().get(0);
280280
Parameters p = arg.getClass().getAnnotation(Parameters.class);
281281

282282
if (p == null || !p.hidden()) {
283283
if (!firstCommand) {
284-
out.append("\n");
284+
out.append('\n');
285285
} else {
286286
firstCommand = false;
287287
}
@@ -292,7 +292,7 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn
292292
.orElse("");
293293
String description = indent + s(4) + dispName + commandDescription;
294294
wrapDescription(out, indentCount + descriptionIndent, description);
295-
out.append("\n");
295+
out.append('\n');
296296

297297
// Options for this command
298298
JCommander jc = commander.findCommandByAlias(progName.getName());
@@ -369,7 +369,7 @@ public void wrapDescription(StringBuilder out, int indent, int currentLineIndent
369369
current++;
370370
}
371371
} else {
372-
out.append("\n").append(s(indent)).append(word).append(" ");
372+
out.append('\n').append(s(indent)).append(word).append(" ");
373373
current = indent + word.length() + 1;
374374
}
375375
}

src/main/java/com/beust/jcommander/UnixStyleUsageFormatter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin
102102
// The magic value 3 is the number of spaces between the name of the option and its description
103103
// in DefaultUsageFormatter#appendCommands(..)
104104
wrapDescription(out, indentCount + prefixIndent - 3, initialLinePrefixLength, description);
105-
out.append("\n");
105+
out.append('\n');
106106
}
107107
}
108108
}

src/test/java/com/beust/jcommander/StringBuilderConsole.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void print(String msg) {
1818
@Override
1919
public void println(String msg) {
2020
print(msg);
21-
output.append("\n");
21+
output.append('\n');
2222
}
2323

2424
@Override

0 commit comments

Comments
 (0)