Skip to content

Commit 3cf156e

Browse files
committed
Fixed sonar
1 parent acb40f2 commit 3cf156e

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

src/main/java/g1801_1900/s1825_finding_mk_average/MKAverage.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
import java.util.LinkedList;
77
import java.util.TreeSet;
88

9-
@SuppressWarnings("java:S2184")
109
public class MKAverage {
11-
private int capacity;
12-
private int boundary;
13-
private int[] nums;
14-
private TreeSet<Integer> numSet;
15-
private LinkedList<Integer> order;
10+
private final int capacity;
11+
private final int boundary;
12+
private final int[] nums;
13+
private final TreeSet<Integer> numSet;
14+
private final LinkedList<Integer> order;
1615

1716
public MKAverage(int m, int k) {
1817
this.capacity = m;
@@ -63,7 +62,9 @@ public int calculateMKAverage() {
6362
}
6463
}
6564

66-
/**
67-
* Your MKAverage object will be instantiated and called as such: MKAverage obj = new MKAverage(m,
68-
* k); obj.addElement(num); int param_2 = obj.calculateMKAverage();
65+
/*
66+
* Your MKAverage object will be instantiated and called as such:
67+
* MKAverage obj = new MKAverage(m, k);
68+
* obj.addElement(num);
69+
* int param_2 = obj.calculateMKAverage();
6970
*/

src/main/java/g3401_3500/s3425_longest_special_path/Solution.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9-
@SuppressWarnings("unchecked")
9+
@SuppressWarnings({"java:S107", "unchecked"})
1010
public class Solution {
1111
public int[] longestSpecialPath(int[][] edges, int[] nums) {
1212
int n = edges.length + 1;

src/test/java/g1801_1900/s1825_finding_mk_average/MKAverageTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,18 @@ void mKAverage() {
1919
obj.addElement(5);
2020
assertThat(obj.calculateMKAverage(), equalTo(5));
2121
}
22+
23+
@Test
24+
void mKAverage2() {
25+
MKAverage obj = new MKAverage(6, 1);
26+
obj.addElement(3);
27+
obj.addElement(1);
28+
assertThat(obj.calculateMKAverage(), equalTo(-1));
29+
obj.addElement(12);
30+
assertThat(obj.calculateMKAverage(), equalTo(-1));
31+
obj.addElement(5);
32+
obj.addElement(3);
33+
obj.addElement(4);
34+
assertThat(obj.calculateMKAverage(), equalTo(3));
35+
}
2236
}

0 commit comments

Comments
 (0)