Skip to content

Commit a2ba20f

Browse files
committed
Fix lint
1 parent 9bc6bf3 commit a2ba20f

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

src/main/java/com/thealgorithms/others/SkylineProblem.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ public List<Skyline> findSkyline(int start, int end) {
110110
public List<Skyline> mergeSkyline(List<Skyline> sky1, List<Skyline> sky2) {
111111
Objects.requireNonNull(sky1, "sky1 must not be null");
112112
Objects.requireNonNull(sky2, "sky2 must not be null");
113-
int i = 0, j = 0;
114-
int h1 = 0, h2 = 0;
113+
int i = 0;
114+
int j = 0;
115+
int h1 = 0;
116+
int h2 = 0;
115117
int prevHeight = 0;
116118
List<Skyline> result = new ArrayList<>();
117119
while (i < sky1.size() && j < sky2.size()) {
@@ -177,8 +179,12 @@ public Skyline(int coordinates, int height) {
177179

178180
@Override
179181
public boolean equals(Object o) {
180-
if (this == o) return true;
181-
if (o == null || getClass() != o.getClass()) return false;
182+
if (this == o) {
183+
return true;
184+
}
185+
if (o == null || getClass() != o.getClass()) {
186+
return false;
187+
}
182188
Skyline skyline = (Skyline) o;
183189
return coordinates == skyline.coordinates && height == skyline.height;
184190
}

src/test/java/com/thealgorithms/others/SkylineProblemTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.thealgorithms.others;
22

3-
import static org.junit.jupiter.api.Assertions.*;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
5+
import static org.junit.jupiter.api.Assertions.assertThrows;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
47

5-
import java.util.*;
8+
import java.util.List;
69
import org.junit.jupiter.api.Test;
710

8-
public class SkylineProblemTest {
11+
class SkylineProblemTest {
912

1013
@Test
1114
void testSingleBuildingSkyline() {
@@ -95,8 +98,18 @@ void testFindSkylineInvalidCases() {
9598
@Test
9699
void testMergeSkylineNullCases() {
97100
SkylineProblem skylineProblem = new SkylineProblem();
98-
Exception ex1 = assertThrows(NullPointerException.class, () -> skylineProblem.mergeSkyline(null, List.of()));
99-
Exception ex2 = assertThrows(NullPointerException.class, () -> skylineProblem.mergeSkyline(List.of(), null));
101+
Exception ex1 = assertThrows(NullPointerException.class, new org.junit.jupiter.api.function.Executable() {
102+
@Override
103+
public void execute() {
104+
skylineProblem.mergeSkyline(null, List.of());
105+
}
106+
});
107+
Exception ex2 = assertThrows(NullPointerException.class, new org.junit.jupiter.api.function.Executable() {
108+
@Override
109+
public void execute() {
110+
skylineProblem.mergeSkyline(List.of(), null);
111+
}
112+
});
100113
assertTrue(ex1.getMessage().contains("sky1"));
101114
assertTrue(ex2.getMessage().contains("sky2"));
102115
}

0 commit comments

Comments
 (0)