Skip to content

Commit f00375d

Browse files
authored
Merge pull request #304 from sir-gon/develop
[BUGFIX] sonarcloud (Maintainability): Remove this 'public' modifier.
2 parents 9047936 + 0e06cc5 commit f00375d

19 files changed

+138
-175
lines changed

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays/ArraysLeftRotationTest.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class ArraysLeftRotationTestCase {
2222
List<ArraysLeftRotationTestCase> testCases;
2323

2424
@BeforeAll
25-
public void setup() throws IOException {
25+
void setup() throws IOException {
2626

2727
String path = String.join("/", "hackerrank",
2828
"interview_preparation_kit",
@@ -32,22 +32,22 @@ public void setup() throws IOException {
3232
this.testCases = JsonLoader.loadJson(path, ArraysLeftRotationTestCase.class);
3333
}
3434

35-
@Test void testRotLeftOne() {
35+
@Test
36+
void testRotLeftOne() {
3637

3738
for (ArraysLeftRotationTestCase test : this.testCases) {
3839
List<Integer> solutionFound = ArraysLeftRotation.rotLeftOne(test.input);
3940

4041
assertEquals(test.expected, solutionFound,
4142
"%s(%s) answer must be: %s".formatted(
42-
"ArraysLeftRotation.rotLeftOne",
43-
test.input,
44-
test.expected
45-
)
46-
);
43+
"ArraysLeftRotation.rotLeftOne",
44+
test.input,
45+
test.expected));
4746
}
4847
}
4948

50-
@Test void testRotLeft() {
49+
@Test
50+
void testRotLeft() {
5151
List<Integer> input = Arrays.asList(1, 2, 3, 4, 5);
5252
List<Integer> expected = Arrays.asList(5, 1, 2, 3, 4);
5353
Integer d = 4;
@@ -59,8 +59,6 @@ public void setup() throws IOException {
5959
"ArraysLeftRotation.rotLeftOne",
6060
input,
6161
d,
62-
expected
63-
)
64-
);
62+
expected));
6563
}
6664
}

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays/CrushBruteForceTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class CrushBruteForceTestCase {
2323
List<CrushBruteForceTestCase> testCases;
2424

2525
@BeforeAll
26-
public void setup() throws IOException {
26+
void setup() throws IOException {
2727

2828
String path = String.join("/", "hackerrank",
2929
"interview_preparation_kit",
@@ -32,19 +32,18 @@ public void setup() throws IOException {
3232
this.testCases = JsonLoader.loadJson(path, CrushBruteForceTestCase.class);
3333
}
3434

35-
@Test void testArrayManipulation() {
35+
@Test
36+
void testArrayManipulation() {
3637
for (CrushBruteForceTestCase testCase : testCases) {
3738
long solutionFound = CrushBruteForce
3839
.arrayManipulation(testCase.n, testCase.queries);
3940

4041
assertEquals(testCase.expected, solutionFound,
4142
"%s(%d, %s) answer must be: %s".formatted(
42-
"CrushBruteForce.arrayManipulation",
43-
testCase.n,
44-
testCase.queries.toString(),
45-
testCase.expected
46-
)
47-
);
43+
"CrushBruteForce.arrayManipulation",
44+
testCase.n,
45+
testCase.queries.toString(),
46+
testCase.expected));
4847
}
4948
}
5049
}

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays/CrushTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.junit.jupiter.api.TestInstance.Lifecycle;
1111
import util.JsonLoader;
1212

13-
1413
@TestInstance(Lifecycle.PER_CLASS)
1514
class CrushTest {
1615

@@ -24,7 +23,7 @@ public static class CrushTestCase {
2423
List<CrushTestCase> testCases;
2524

2625
@BeforeAll
27-
public void setup() throws IOException {
26+
void setup() throws IOException {
2827
String path = String.join("/", "hackerrank",
2928
"interview_preparation_kit",
3029
"arrays",
@@ -33,19 +32,18 @@ public void setup() throws IOException {
3332
this.testCases = JsonLoader.loadJson(path, CrushTestCase.class);
3433
}
3534

36-
@Test void testArrayManipulation() {
35+
@Test
36+
void testArrayManipulation() {
3737
for (CrushTestCase testCase : testCases) {
3838
long solutionFound = CrushOptimized
3939
.arrayManipulation(testCase.n, testCase.queries);
4040

4141
assertEquals(testCase.expected, solutionFound,
4242
"%s(%d, %s) answer must be: %s".formatted(
43-
"CrushOptimized.arrayManipulation",
44-
testCase.n,
45-
testCase.queries.toString(),
46-
testCase.expected
47-
)
48-
);
43+
"CrushOptimized.arrayManipulation",
44+
testCase.n,
45+
testCase.queries.toString(),
46+
testCase.expected));
4947
}
5048
}
5149
}

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays/MinimumSwaps2Test.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.junit.jupiter.api.TestInstance.Lifecycle;
1111
import util.JsonLoader;
1212

13-
1413
@TestInstance(Lifecycle.PER_CLASS)
1514
class MinimumSwaps2Test {
1615

@@ -23,7 +22,7 @@ public static class MinimumSwaps2TestCase {
2322
List<MinimumSwaps2TestCase> testCases;
2423

2524
@BeforeAll
26-
public void setup() throws IOException {
25+
void setup() throws IOException {
2726
String path = String.join("/", "hackerrank",
2827
"interview_preparation_kit",
2928
"arrays",
@@ -32,7 +31,8 @@ public void setup() throws IOException {
3231
this.testCases = JsonLoader.loadJson(path, MinimumSwaps2TestCase.class);
3332
}
3433

35-
@Test void testArrayManipulation() {
34+
@Test
35+
void testArrayManipulation() {
3636
for (MinimumSwaps2TestCase testCase : testCases) {
3737
int[] input = testCase.input
3838
.stream()
@@ -42,11 +42,9 @@ public void setup() throws IOException {
4242

4343
assertEquals(testCase.expected, solutionFound,
4444
"%s(%s) answer must be: %s".formatted(
45-
"MinimumSwaps2.minimumSwaps",
46-
testCase.input.toString(),
47-
testCase.expected
48-
)
49-
);
45+
"MinimumSwaps2.minimumSwaps",
46+
testCase.input.toString(),
47+
testCase.expected));
5048
}
5149
}
5250
}

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays/NewYearChaosTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class NewYearChaosTestCase {
2222
List<NewYearChaosTestCase> testCases;
2323

2424
@BeforeAll
25-
public void setup() throws IOException {
25+
void setup() throws IOException {
2626

2727
String path = String.join("/", "hackerrank",
2828
"interview_preparation_kit",
@@ -32,19 +32,18 @@ public void setup() throws IOException {
3232
this.testCases = JsonLoader.loadJson(path, NewYearChaosTestCase.class);
3333
}
3434

35-
@Test void testMinimumBribesText() {
35+
@Test
36+
void testMinimumBribesText() {
3637

3738
for (NewYearChaosTestCase test : this.testCases) {
3839
String solutionFound = NewYearChaos.minimumBribesText(test.input);
3940
NewYearChaos.minimumBribes(test.input);
4041

4142
assertEquals(test.expected, solutionFound,
4243
"%s(%s) answer must be: %s".formatted(
43-
"NewYearChaosTestCase.minimumBribesText",
44-
test.input,
45-
test.expected
46-
)
47-
);
44+
"NewYearChaosTestCase.minimumBribesText",
45+
test.input,
46+
test.expected));
4847
}
4948
}
5049

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/arrays/TwoDarrayTest.java

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.junit.jupiter.api.TestInstance.Lifecycle;
1212
import util.JsonLoader;
1313

14-
1514
@TestInstance(Lifecycle.PER_CLASS)
1615
class TwoDarrayTest {
1716

@@ -24,7 +23,7 @@ public static class TwoDarrayTestCase {
2423
private List<TwoDarrayTestCase> testCases;
2524

2625
@BeforeAll
27-
public void setup() throws IOException {
26+
void setup() throws IOException {
2827
String path = String.join("/", "hackerrank",
2928
"interview_preparation_kit",
3029
"arrays",
@@ -33,44 +32,38 @@ public void setup() throws IOException {
3332
this.testCases = JsonLoader.loadJson(path, TwoDarrayTestCase.class);
3433
}
3534

36-
37-
@Test void testHourglassSum() {
35+
@Test
36+
void testHourglassSum() {
3837
for (TwoDarrayTestCase testCase : testCases) {
3938
long solutionFound = TwoDarray.hourglassSum(testCase.input);
4039

4140
assertEquals(testCase.expected, solutionFound,
4241
"%s(%s) answer must be: %s".formatted(
43-
"TwoDarray.hourglassSum",
44-
testCase.input.toString(),
45-
testCase.expected
46-
)
47-
);
42+
"TwoDarray.hourglassSum",
43+
testCase.input.toString(),
44+
testCase.expected));
4845
}
4946
}
5047

51-
@Test void testHourglassSumEdgeCases() {
48+
@Test
49+
void testHourglassSumEdgeCases() {
5250
List<List<Integer>> input = null;
5351
Integer expected = null;
5452
Integer solutionFound = TwoDarray.hourglassSum(null);
5553
assertEquals(expected, solutionFound,
5654
"%s(%s) answer must be: %s".formatted(
57-
"TwoDarray.hourglassSum",
58-
input,
59-
expected
60-
)
61-
);
55+
"TwoDarray.hourglassSum",
56+
input,
57+
expected));
6258

6359
input = new ArrayList<List<Integer>>();
6460
expected = null;
6561
solutionFound = TwoDarray.hourglassSum(null);
6662

6763
assertEquals(expected, solutionFound,
6864
"%s(%s) answer must be: %s".formatted(
69-
"TwoDarray.hourglassSum",
70-
input,
71-
expected
72-
)
73-
);
65+
"TwoDarray.hourglassSum",
66+
input,
67+
expected));
7468
}
7569
}
76-

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/RansomNoteTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static class RansomNoteTestCase {
2323
List<RansomNoteTestCase> testCases;
2424

2525
@BeforeAll
26-
public void setup() throws IOException {
26+
void setup() throws IOException {
2727
String path = String.join("/", "hackerrank",
2828
"interview_preparation_kit",
2929
"dictionaries_and_hashmaps",
@@ -32,18 +32,17 @@ public void setup() throws IOException {
3232
this.testCases = JsonLoader.loadJson(path, RansomNoteTestCase.class);
3333
}
3434

35-
@Test void testArrayManipulation() {
35+
@Test
36+
void testArrayManipulation() {
3637
for (RansomNoteTestCase test : testCases) {
3738
String solutionFound = RansomNote.checkMagazine(test.magazine, test.note);
3839

3940
assertEquals(test.expected, solutionFound,
4041
"%s(%s, %s) answer must be: %s".formatted(
41-
"RansomNote.checkMagazine",
42-
test.magazine,
43-
test.note,
44-
test.expected
45-
)
46-
);
42+
"RansomNote.checkMagazine",
43+
test.magazine,
44+
test.note,
45+
test.expected));
4746
}
4847
}
4948
}

algorithm-exercises-java/src/test/java/ae/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/TwoStringsTest.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/**
1414
* TwoStringsTest.
15-
*/
15+
*/
1616
@TestInstance(Lifecycle.PER_CLASS)
1717
class TwoStringsTest {
1818
public static class TwoStringsTestCase {
@@ -25,28 +25,27 @@ public static class TwoStringsTestCase {
2525
private List<TwoStringsTestCase> testCases;
2626

2727
@BeforeAll
28-
public void setup() throws IOException {
28+
void setup() throws IOException {
2929
String path = String.join("/",
30-
"hackerrank",
30+
"hackerrank",
3131
"interview_preparation_kit",
3232
"dictionaries_and_hashmaps",
3333
"two_strings.testcases.json");
3434

3535
this.testCases = JsonLoader.loadJson(path, TwoStringsTestCase.class);
3636
}
3737

38-
@Test void testTwoStrings() {
38+
@Test
39+
void testTwoStrings() {
3940
for (TwoStringsTestCase test : testCases) {
4041
String solutionFound = TwoStrings.twoStrings(test.s1, test.s2);
4142

4243
assertEquals(test.expected, solutionFound,
4344
"%s(%s, %s) answer must be: %s".formatted(
44-
"TwoStrings.twoStrings",
45-
test.s1,
46-
test.s2,
47-
test.expected
48-
)
49-
);
45+
"TwoStrings.twoStrings",
46+
test.s1,
47+
test.s2,
48+
test.expected));
5049
}
5150
}
5251
}

0 commit comments

Comments
 (0)