Skip to content

Commit 6a9e30e

Browse files
committed
[Feature/JShell] Added braces
1 parent 57eb316 commit 6a9e30e

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/RendererUtils.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,24 @@ enum GeneralStatus {
3939
}
4040

4141
static GeneralStatus getGeneralStatus(JShellResult result) {
42-
if (result.snippetsResults().isEmpty() && result.abortion() == null)
42+
if (result.snippetsResults().isEmpty() && result.abortion() == null) {
4343
return GeneralStatus.SUCCESS; // Empty = success
44-
if (result.snippetsResults().isEmpty())
44+
}
45+
if (result.snippetsResults().isEmpty()) {
4546
return GeneralStatus.ERROR; // Only abortion = failure, special case for syntax error
47+
}
4648
if (result.snippetsResults().size() == 1 && result.abortion() != null // Only abortion =
4749
// failure, case for
4850
// all except syntax
4951
// error
5052
&& !(result.abortion()
51-
.cause() instanceof JShellEvalAbortionCause.SyntaxErrorAbortionCause))
53+
.cause() instanceof JShellEvalAbortionCause.SyntaxErrorAbortionCause)) {
5254
return GeneralStatus.ERROR;
55+
}
5356

54-
if (result.abortion() != null)
57+
if (result.abortion() != null) {
5558
return GeneralStatus.PARTIAL_SUCCESS; // At least one snippet is a success
59+
}
5660

5761
return getGeneralStatus(
5862
result.snippetsResults().get(result.snippetsResults().size() - 1).status());

application/src/main/java/org/togetherjava/tjbot/features/jshell/renderer/ResultEmbedRenderer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ private void setResultToEmbed(boolean showCode, List<String> builder, JShellResu
6161
}
6262

6363
private String resultToString(@Nullable String result) {
64-
if (result == null || result.isEmpty())
64+
if (result == null || result.isEmpty()) {
6565
return "";
66-
if (!result.contains("\n"))
66+
}
67+
if (!result.contains("\n")) {
6768
return "\njshell> `" + result + "`";
68-
return "\njshell> ↓```\n" + result + "```";
69+
} else {
70+
return "\njshell> ↓```\n" + result + "```";
71+
}
6972
}
7073

7174
private String abortionToString(JShellEvalAbortion abortion) {

0 commit comments

Comments
 (0)