Skip to content

Commit b51be57

Browse files
Fix Sonar issue
1 parent 1f5d3b1 commit b51be57

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

src/main/java/io/github/computerdaddyguy/jfiletreeprettyprinter/PathPredicateBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public PathPredicateBuilder hasExtension(String extension) {
198198
* @return this builder for chaining
199199
*/
200200
public PathPredicateBuilder isDirectory() {
201-
return pathTest(path -> PathPredicates.isDirectory(path));
201+
return pathTest(PathPredicates::isDirectory);
202202
}
203203

204204
/**
@@ -207,7 +207,7 @@ public PathPredicateBuilder isDirectory() {
207207
* @return this builder for chaining
208208
*/
209209
public PathPredicateBuilder isFile() {
210-
return pathTest(path -> PathPredicates.isFile(path));
210+
return pathTest(PathPredicates::isFile);
211211
}
212212

213213
// ---------- Hierarchy ----------

src/test/java/io/github/computerdaddyguy/jfiletreeprettyprinter/PathPredicateBuilderTest.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ void does_not_match_grandparent() throws IOException {
360360
}
361361

362362
@Test
363+
@SuppressWarnings("unused")
363364
void does_not_match_sibling() throws IOException {
364365
var parent = createTempDir("parent");
365366
var child = Files.createDirectory(parent.resolve("child"));
@@ -374,14 +375,14 @@ void does_not_match_sibling() throws IOException {
374375
}
375376

376377
@Test
377-
void root_has_no_parent() throws IOException {
378-
var root = Path.of("root");
378+
void root_has_no_parent() {
379+
var detachedRoot = Path.of("root");
379380

380381
var filter = PathPredicates.builder().hasParentMatching(
381382
p -> true
382383
).build();
383384

384-
assertThat(filter.test(root)).isFalse();
385+
assertThat(filter.test(detachedRoot)).isFalse();
385386
}
386387

387388
}
@@ -422,6 +423,7 @@ void matches_grandparent() throws IOException {
422423
}
423424

424425
@Test
426+
@SuppressWarnings("unused")
425427
void does_not_match_sibling() throws IOException {
426428
var parent = createTempDir("parent");
427429
var child = Files.createDirectory(parent.resolve("child"));
@@ -436,14 +438,14 @@ void does_not_match_sibling() throws IOException {
436438
}
437439

438440
@Test
439-
void root_has_no_parent() throws IOException {
440-
var root = Path.of("root");
441+
void root_has_no_parent() {
442+
var detachedRoot = Path.of("root");
441443

442444
var filter = PathPredicates.builder().hasAncestorMatching(
443445
p -> true
444446
).build();
445447

446-
assertThat(filter.test(root)).isFalse();
448+
assertThat(filter.test(detachedRoot)).isFalse();
447449
}
448450

449451
}
@@ -458,6 +460,7 @@ void null_predicate_throws_NPE() {
458460
}
459461

460462
@Test
463+
@SuppressWarnings("unused")
461464
void matches_direct_child() throws IOException {
462465
var parent = createTempDir("parent");
463466
var child = Files.createDirectory(parent.resolve("child"));
@@ -470,6 +473,7 @@ void matches_direct_child() throws IOException {
470473
}
471474

472475
@Test
476+
@SuppressWarnings("unused")
473477
void does_not_match_grandchild() throws IOException {
474478
var parent = createTempDir("parent");
475479
var child = Files.createDirectory(parent.resolve("child"));
@@ -483,7 +487,7 @@ void does_not_match_grandchild() throws IOException {
483487
}
484488

485489
@Test
486-
void does_not_match_if_not_directory() throws IOException {
490+
void does_not_match_if_not_directory() {
487491
var parent = createTempFile("parent");
488492

489493
var filter = PathPredicates.builder().hasDirectChildMatching(
@@ -494,7 +498,7 @@ void does_not_match_if_not_directory() throws IOException {
494498
}
495499

496500
@Test
497-
void does_not_match_if_no_child() throws IOException {
501+
void does_not_match_if_no_child() {
498502
var parent = createTempDir("parent");
499503

500504
var filter = PathPredicates.builder().hasDirectChildMatching(
@@ -516,6 +520,7 @@ void null_predicate_throws_NPE() {
516520
}
517521

518522
@Test
523+
@SuppressWarnings("unused")
519524
void matches_grandchild() throws IOException {
520525
var parent = createTempDir("parent");
521526
var child = Files.createDirectory(parent.resolve("child"));
@@ -541,7 +546,7 @@ void does_not_match_nonexistent_descendant() {
541546
}
542547

543548
@Test
544-
void does_not_match_if_not_directory() throws IOException {
549+
void does_not_match_if_not_directory() {
545550
var parent = createTempFile("parent");
546551

547552
var filter = PathPredicates.builder().hasDescendantMatching(
@@ -552,7 +557,7 @@ void does_not_match_if_not_directory() throws IOException {
552557
}
553558

554559
@Test
555-
void does_not_match_if_no_child() throws IOException {
560+
void does_not_match_if_no_child() {
556561
var parent = createTempDir("parent");
557562

558563
var filter = PathPredicates.builder().hasDescendantMatching(
@@ -574,6 +579,7 @@ void null_predicate_throws_NPE() {
574579
}
575580

576581
@Test
582+
@SuppressWarnings("unused")
577583
void matches_sibling() throws IOException {
578584
var parent = createTempDir("parent");
579585
var child1 = Files.createDirectory(parent.resolve("child1"));
@@ -587,6 +593,7 @@ void matches_sibling() throws IOException {
587593
}
588594

589595
@Test
596+
@SuppressWarnings("unused")
590597
void matches_sibling_failed() throws IOException {
591598
var parent = createTempDir("parent");
592599
var child1 = Files.createDirectory(parent.resolve("child1"));
@@ -600,7 +607,7 @@ void matches_sibling_failed() throws IOException {
600607
}
601608

602609
@Test
603-
void root_has_no_sibling() throws IOException {
610+
void root_has_no_sibling() {
604611
var root = Path.of("root");
605612

606613
var filter = PathPredicates.builder().hasSiblingMatching(
@@ -623,6 +630,7 @@ void does_not_match_self() throws IOException {
623630
}
624631

625632
@Test
633+
@SuppressWarnings("unused")
626634
void does_not_match_parent_or_child() throws IOException {
627635
var parent = createTempDir("parent");
628636
var child = Files.createDirectory(parent.resolve("child"));

0 commit comments

Comments
 (0)