Skip to content

Commit 64813e0

Browse files
Fix Sonar
1 parent ad033a2 commit 64813e0

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

src/main/java/io/github/computerdaddyguy/jfiletreeprettyprinter/cli/RecordUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public static String toTextBlock(@Nullable Record rec) {
2828
private static void toTextBlock(List<String> lines, String shift, @Nullable String attrName, @Nullable Object value, String indent) {
2929
if (value == null) {
3030
return; // do not print null objects, just ignore them
31-
} else if (value.getClass().isRecord()) {
31+
}
32+
if (value.getClass().isRecord()) {
3233
toTextBlockRecord(lines, shift, attrName, (Record) value, indent);
3334
} else if (value instanceof Collection<?> coll) {
3435
toTextBlockCollection(lines, shift, attrName, coll, indent);

src/main/java/io/github/computerdaddyguy/jfiletreeprettyprinter/cli/io/DefaultConsoleOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private void printErr(String msg, Object... args) {
7070
}
7171

7272
private void printfln(PrintStream dest, String msg, Object... args) {
73-
dest.printf(msg + "\n", args);// Because "printf" does not print line return
73+
dest.printf("%s%s", msg, System.lineSeparator(), args);// Because "printf" does not print line return
7474
}
7575

7676
}

src/main/java/io/github/computerdaddyguy/jfiletreeprettyprinter/cli/options/mapper/DefaultExternalOptionsMapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ private PrettyPrintOptions mapCompactDirectories(PrettyPrintOptions options, Ext
3939
}
4040

4141
private PrettyPrintOptions mapMaxDepth(PrettyPrintOptions options, ExternalOptions externalOptions) {
42-
if (externalOptions.maxDepth() != null) {
43-
return options.withMaxDepth(externalOptions.maxDepth());
42+
var max = externalOptions.maxDepth();
43+
if (max != null) {
44+
return options.withMaxDepth(max);
4445
}
4546
return options;
4647
}

src/test/java/io/github/computerdaddyguy/jfiletreeprettyprinter/cli/FileTreePrettyPrinterCommandLineTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import io.github.computerdaddyguy.jfiletreeprettyprinter.cli.options.OptionsLoader;
1010
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.ChildLimits;
1111
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PathMatchers;
12+
import io.github.computerdaddyguy.jfiletreeprettyprinter.options.PrettyPrintOptions;
1213
import java.io.ByteArrayOutputStream;
13-
import java.io.IOException;
1414
import java.io.PrintStream;
1515
import java.nio.file.Path;
1616
import java.util.function.Consumer;
@@ -53,7 +53,7 @@ private void runErrorTest(FileTreePrettyPrinterCommandLine cli, String[] args, C
5353
}
5454

5555
@Test
56-
void no_options() throws IOException {
56+
void no_options() {
5757
String targetPath = "src/test/resources/cli/base";
5858
String optionsPath = null;
5959
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -68,7 +68,7 @@ void no_options() throws IOException {
6868
}
6969

7070
@Test
71-
void unexisting_options() throws IOException {
71+
void unexisting_options() {
7272
String targetPath = "src/test/resources/cli/base";
7373
String optionsPath = "not_existing";
7474
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -82,7 +82,7 @@ void unexisting_options() throws IOException {
8282
}
8383

8484
@Test
85-
void malformed_options() throws IOException {
85+
void malformed_options() {
8686
String targetPath = "src/test/resources/cli/base";
8787
String optionsPath = "src/test/resources/cli/options/malformed.yaml";
8888
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -96,7 +96,7 @@ void malformed_options() throws IOException {
9696
}
9797

9898
@Test
99-
void invalid_options() throws IOException {
99+
void invalid_options() {
100100
String targetPath = "src/test/resources/cli/base";
101101
String optionsPath = "src/test/resources/cli/options/invalid.yaml";
102102
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -116,7 +116,7 @@ void invalid_options() throws IOException {
116116
class Emojis {
117117

118118
@Test
119-
void emojis() throws IOException {
119+
void nominal() {
120120
String targetPath = "src/test/resources/cli/base";
121121
String optionsPath = "src/test/resources/cli/options/emojis.yaml";
122122
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -126,7 +126,7 @@ void emojis() throws IOException {
126126
var cli = new FileTreePrettyPrinterCommandLine(output, optionsLoader, exHandler);
127127

128128
var ref = FileTreePrettyPrinter.builder()
129-
.customizeOptions(options -> options.withDefaultEmojis())
129+
.customizeOptions(PrettyPrintOptions::withDefaultEmojis)
130130
.build();
131131

132132
runSuccessTest(cli, args, ref, targetPath);
@@ -138,7 +138,7 @@ void emojis() throws IOException {
138138
class CompactDirectories {
139139

140140
@Test
141-
void emojis() throws IOException {
141+
void nominal() {
142142
String targetPath = "src/test/resources/cli/base";
143143
String optionsPath = "src/test/resources/cli/options/compactDirectories.yaml";
144144
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -160,7 +160,7 @@ void emojis() throws IOException {
160160
class MaxDepth {
161161

162162
@Test
163-
void emojis() throws IOException {
163+
void nominal() {
164164
String targetPath = "src/test/resources/cli/base";
165165
String optionsPath = "src/test/resources/cli/options/maxDepth.yaml";
166166
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -182,7 +182,7 @@ void emojis() throws IOException {
182182
class ChildLimit {
183183

184184
@Test
185-
void static_limit() throws IOException {
185+
void static_limit() {
186186
String targetPath = "src/test/resources/cli/base";
187187
String optionsPath = "src/test/resources/cli/options/childLimit_static.yaml";
188188
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -199,7 +199,7 @@ void static_limit() throws IOException {
199199
}
200200

201201
@Test
202-
void dynamic_limit_glob() throws IOException {
202+
void dynamic_limit_glob() {
203203
String targetPath = "src/test/resources/cli/base";
204204
String optionsPath = "src/test/resources/cli/options/childLimit_dynamic_glob.yaml";
205205
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -220,7 +220,7 @@ void dynamic_limit_glob() throws IOException {
220220
}
221221

222222
@Test
223-
void dynamic_limit_everything() throws IOException {
223+
void dynamic_limit_everything() {
224224
String targetPath = "src/test/resources/cli/base";
225225
String optionsPath = "src/test/resources/cli/options/childLimit_dynamic_everything.yaml";
226226
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -240,7 +240,7 @@ void dynamic_limit_everything() throws IOException {
240240
}
241241

242242
@Test
243-
void dynamic_limit_allOf() throws IOException {
243+
void dynamic_limit_allOf() {
244244
String targetPath = "src/test/resources/cli/base";
245245
String optionsPath = "src/test/resources/cli/options/childLimit_dynamic_allOf.yaml";
246246
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -261,7 +261,7 @@ void dynamic_limit_allOf() throws IOException {
261261
}
262262

263263
@Test
264-
void dynamic_limit_anyOf() throws IOException {
264+
void dynamic_limit_anyOf() {
265265
String targetPath = "src/test/resources/cli/base";
266266
String optionsPath = "src/test/resources/cli/options/childLimit_dynamic_anyOf.yaml";
267267
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -282,7 +282,7 @@ void dynamic_limit_anyOf() throws IOException {
282282
}
283283

284284
@Test
285-
void dynamic_limit_noneOf() throws IOException {
285+
void dynamic_limit_noneOf() {
286286
String targetPath = "src/test/resources/cli/base";
287287
String optionsPath = "src/test/resources/cli/options/childLimit_dynamic_noneOf.yaml";
288288
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -308,7 +308,7 @@ void dynamic_limit_noneOf() throws IOException {
308308
class Filter {
309309

310310
@Test
311-
void nominal() throws IOException {
311+
void nominal() {
312312
String targetPath = "src/test/resources/cli/base";
313313
String optionsPath = "src/test/resources/cli/options/filter.yaml";
314314
String[] args = buildCliArgs(targetPath, optionsPath);
@@ -331,7 +331,7 @@ void nominal() throws IOException {
331331
class LineExtensions {
332332

333333
@Test
334-
void nominal() throws IOException {
334+
void nominal() {
335335
String targetPath = "src/test/resources/cli/base";
336336
String optionsPath = "src/test/resources/cli/options/lineExtensions.yaml";
337337
String[] args = buildCliArgs(targetPath, optionsPath);

0 commit comments

Comments
 (0)