Skip to content

Commit 9e6b430

Browse files
author
Fischstaebchen
committed
Checkstyle fixes.
1 parent 378a113 commit 9e6b430

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/main/java/net/javadiscord/javabot/util/IndentationHelper.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ public static String formatIndentation(String text, IndentationType type) {
104104
boolean startOfLine = true;
105105
for (int i = 0; i < text.length(); i++) {
106106
char current = text.charAt(i);
107+
if (startOfLine && current == ' ') {
108+
continue;
109+
}
107110
builder.append(current);
108111
if (current == '\n') {
109112
builder.append(type.getPattern().repeat(Math.max(numberOfBrackets, 0)));
110113
startOfLine = true;
111114
}
112-
if (startOfLine && current == ' ') {
113-
builder.deleteCharAt(builder.length() - 1);
114-
}
115115
switch (currentState) {
116116
case CODE -> {
117117
switch (current) {
@@ -122,8 +122,12 @@ public static String formatIndentation(String text, IndentationType type) {
122122
builder.replace(builder.length() - type.getNumberOfChars() - 1, builder.length(), "}");
123123
}
124124
}
125-
case '\'' -> currentState = IndentationState.CHARACTER;
126-
case '\"' -> currentState = IndentationState.STRING;
125+
case '\'' -> {
126+
currentState = IndentationState.CHARACTER;
127+
}
128+
case '\"' -> {
129+
currentState = IndentationState.STRING;
130+
}
127131
case '/' -> {
128132
if (i + 1 < text.length()) {
129133
if (text.charAt(i + 1) == '/') {
@@ -136,17 +140,13 @@ public static String formatIndentation(String text, IndentationType type) {
136140
}
137141
}
138142
case STRING -> {
139-
if (current == '\"') {
140-
if (!isEscaped(builder, builder.length() - 1)) {
141-
currentState = IndentationState.CODE;
142-
}
143+
if (current == '\"' && !isEscaped(builder, builder.length() - 1)) {
144+
currentState = IndentationState.CODE;
143145
}
144146
}
145147
case CHARACTER -> {
146-
if (current == '\'') {
147-
if (!isEscaped(builder, builder.length() - 1)) {
148-
currentState = IndentationState.CODE;
149-
}
148+
if (current == '\'' && !isEscaped(builder, builder.length() - 1)) {
149+
currentState = IndentationState.CODE;
150150
}
151151
}
152152
case SINGLE_LINE_COMMENT -> {

src/test/java/net/javadiscord/javabot/util/IndentationHelperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
public class IndentationHelperTest {
1717
/**
18-
* Tests the {@link IndentationHelper#formatIndentation(String, IndentationHelper.IndentationType)} method
18+
* Tests the {@link IndentationHelper#formatIndentation(String, IndentationHelper.IndentationType)} method.
1919
*/
2020
@Test
2121
public void testFormatIndentation() {

0 commit comments

Comments
 (0)