diff --git a/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java b/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java index 30d7cb7b..1d564d67 100644 --- a/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java +++ b/src/main/java/com/beust/jcommander/DefaultUsageFormatter.java @@ -67,7 +67,7 @@ public final void usage(String commandName, StringBuilder out, String indent) { if (description != null) { out.append(indent).append(description); - out.append("\n"); + out.append('\n'); } jc.getUsageFormatter().usage(out, indent); } @@ -154,7 +154,7 @@ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean hasCom mainLine.append(" ").append(commander.getMainParameter().getDescription().getDescription()); } wrapDescription(out, indentCount, mainLine.toString()); - out.append("\n"); + out.append('\n'); } /** @@ -169,7 +169,7 @@ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean hasCom public void appendAllParametersDetails(StringBuilder out, int indentCount, String indent, List sortedParameters) { if (sortedParameters.size() > 0) { - out.append("\n"); + out.append('\n'); out.append(indent).append(" Options:\n"); } @@ -183,7 +183,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin .append(" ") .append(parameter.required() ? "* " : " ") .append(pd.getNames()) - .append("\n"); + .append('\n'); if (hasDescription) { wrapDescription(out, indentCount, s(indentCount) + description); @@ -242,7 +242,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin out.append(possibleValues); } } - out.append("\n"); + out.append('\n'); } } @@ -270,10 +270,10 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn if (hasOnlyHiddenCommands) return; - out.append("\n"); + out.append('\n'); out.append(indent + " Commands:\n"); - boolean firstCommand = true; + var firstCommand = true; // The magic value 3 is the number of spaces between the name of the option and its description for (Map.Entry commands : commander.getRawCommands().entrySet()) { Object arg = commands.getValue().getObjects().get(0); @@ -281,7 +281,7 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn if (p == null || !p.hidden()) { if (!firstCommand) { - out.append("\n"); + out.append('\n'); } else { firstCommand = false; } @@ -292,7 +292,7 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn .orElse(""); String description = indent + s(4) + dispName + commandDescription; wrapDescription(out, indentCount + descriptionIndent, description); - out.append("\n"); + out.append('\n'); // Options for this command JCommander jc = commander.findCommandByAlias(progName.getName()); @@ -369,7 +369,7 @@ public void wrapDescription(StringBuilder out, int indent, int currentLineIndent current++; } } else { - out.append("\n").append(s(indent)).append(word).append(" "); + out.append('\n').append(s(indent)).append(word).append(" "); current = indent + word.length() + 1; } } diff --git a/src/main/java/com/beust/jcommander/UnixStyleUsageFormatter.java b/src/main/java/com/beust/jcommander/UnixStyleUsageFormatter.java index e0a16900..16e8c955 100644 --- a/src/main/java/com/beust/jcommander/UnixStyleUsageFormatter.java +++ b/src/main/java/com/beust/jcommander/UnixStyleUsageFormatter.java @@ -102,7 +102,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin // The magic value 3 is the number of spaces between the name of the option and its description // in DefaultUsageFormatter#appendCommands(..) wrapDescription(out, indentCount + prefixIndent - 3, initialLinePrefixLength, description); - out.append("\n"); + out.append('\n'); } } } diff --git a/src/test/java/com/beust/jcommander/StringBuilderConsole.java b/src/test/java/com/beust/jcommander/StringBuilderConsole.java index 36148bb2..39aab03d 100644 --- a/src/test/java/com/beust/jcommander/StringBuilderConsole.java +++ b/src/test/java/com/beust/jcommander/StringBuilderConsole.java @@ -18,7 +18,7 @@ public void print(String msg) { @Override public void println(String msg) { print(msg); - output.append("\n"); + output.append('\n'); } @Override