Skip to content

Commit dc47e0a

Browse files
authored
style: include ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD (#5129)
1 parent 5d00889 commit dc47e0a

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

spotbugs-exclude.xml

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
<Match>
66
<Bug pattern="EI_EXPOSE_REP2" />
77
</Match>
8-
<Match>
9-
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
10-
</Match>
118
<Match>
129
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
1310
</Match>

src/main/java/com/thealgorithms/sorts/LinkListSort.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class Node {
137137

138138
class Task {
139139

140-
static int[] a;
140+
private int[] a;
141141

142142
public Node sortByMergeSort(Node head) {
143143
if (head == null || head.next == null) return head;
@@ -245,7 +245,7 @@ static int count(Node head) {
245245

246246
class Task2 {
247247

248-
static int[] a;
248+
private int[] a;
249249

250250
public Node sortByHeapSort(Node head) {
251251
if (head == null || head.next == null) return head;

src/main/java/com/thealgorithms/sorts/MergeSort.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class MergeSort implements SortAlgorithm {
1111

12-
@SuppressWarnings("rawtypes") private static Comparable[] aux;
12+
private Comparable[] aux;
1313

1414
/**
1515
* Generic merge sort algorithm implements.
@@ -30,7 +30,7 @@ public <T extends Comparable<T>> T[] sort(T[] unsorted) {
3030
* @param left the first index of the array.
3131
* @param right the last index of the array.
3232
*/
33-
private static <T extends Comparable<T>> void doSort(T[] arr, int left, int right) {
33+
private <T extends Comparable<T>> void doSort(T[] arr, int left, int right) {
3434
if (left < right) {
3535
int mid = (left + right) >>> 1;
3636
doSort(arr, left, mid);
@@ -49,7 +49,7 @@ private static <T extends Comparable<T>> void doSort(T[] arr, int left, int righ
4949
* increasing order.
5050
*/
5151
@SuppressWarnings("unchecked")
52-
private static <T extends Comparable<T>> void merge(T[] arr, int left, int mid, int right) {
52+
private <T extends Comparable<T>> void merge(T[] arr, int left, int mid, int right) {
5353
int i = left, j = mid + 1;
5454
System.arraycopy(arr, left, aux, left, right + 1 - left);
5555

src/main/java/com/thealgorithms/sorts/TimSort.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class TimSort implements SortAlgorithm {
1111
private static final int SUB_ARRAY_SIZE = 32;
12-
@SuppressWarnings("rawtypes") private static Comparable[] aux;
12+
private Comparable[] aux;
1313

1414
@Override
1515
public <T extends Comparable<T>> T[] sort(T[] a) {
@@ -30,8 +30,7 @@ public <T extends Comparable<T>> T[] sort(T[] a) {
3030
return a;
3131
}
3232

33-
@SuppressWarnings("unchecked")
34-
private static <T extends Comparable<T>> void merge(T[] a, int lo, int mid, int hi) {
33+
private <T extends Comparable<T>> void merge(T[] a, int lo, int mid, int hi) {
3534
int i = lo, j = mid + 1;
3635
System.arraycopy(a, lo, aux, lo, hi + 1 - lo);
3736

0 commit comments

Comments
 (0)