Skip to content

Commit 26b4b82

Browse files
authored
style: include OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION (#5274)
1 parent 5bc96cf commit 26b4b82

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

spotbugs-exclude.xml

-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@
123123
<Match>
124124
<Bug pattern="BL_BURYING_LOGIC" />
125125
</Match>
126-
<Match>
127-
<Bug pattern="OI_OPTIONAL_ISSUES_USES_IMMEDIATE_EXECUTION" />
128-
</Match>
129126
<Match>
130127
<Bug pattern="PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS" />
131128
</Match>

src/test/java/com/thealgorithms/searches/BreadthFirstSearchTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testSearchRoot() {
5353

5454
// check value
5555
Optional<Node<String>> value = bfs.search(root, expectedValue);
56-
assertEquals(expectedValue, value.orElse(new Node<>("")).getValue());
56+
assertEquals(expectedValue, value.orElseGet(() -> new Node<>("")).getValue());
5757

5858
// check path
5959
assertArrayEquals(expectedPath.toArray(), bfs.getVisited().toArray());
@@ -65,7 +65,7 @@ public void testSearchF() {
6565
List<String> expectedPath = List.of("A", "B", "C", "D", "E", "F");
6666

6767
// check value
68-
Optional<Node<String>> value = Optional.of(bfs.search(root, expectedValue).orElse(new Node<>(null)));
68+
Optional<Node<String>> value = Optional.of(bfs.search(root, expectedValue).orElseGet(() -> new Node<>(null)));
6969
assertEquals(expectedValue, value.get().getValue());
7070

7171
// check path

src/test/java/com/thealgorithms/searches/DepthFirstSearchTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testSearchRoot() {
5454

5555
// check value
5656
Optional<Node<Integer>> value = dfs.recursiveSearch(root, expectedValue);
57-
assertEquals(expectedValue, value.orElse(new Node<>(null)).getValue());
57+
assertEquals(expectedValue, value.orElseGet(() -> new Node<>(null)).getValue());
5858

5959
// check path
6060
assertArrayEquals(expectedPath.toArray(), dfs.getVisited().toArray());
@@ -67,7 +67,7 @@ public void testSearch4() {
6767

6868
// check value
6969
Optional<Node<Integer>> value = dfs.recursiveSearch(root, expectedValue);
70-
assertEquals(expectedValue, value.orElse(new Node<>(null)).getValue());
70+
assertEquals(expectedValue, value.orElseGet(() -> new Node<>(null)).getValue());
7171

7272
// check path
7373
assertArrayEquals(expectedPath.toArray(), dfs.getVisited().toArray());

0 commit comments

Comments
 (0)