From dc47e0aa42132bd67b12e88993497df35a3cc25d Mon Sep 17 00:00:00 2001
From: Piotr Idzik <65706193+vil02@users.noreply.github.com>
Date: Sun, 5 May 2024 20:39:26 +0200
Subject: [PATCH] style: include `ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD`
(#5129)
---
spotbugs-exclude.xml | 3 ---
src/main/java/com/thealgorithms/sorts/LinkListSort.java | 4 ++--
src/main/java/com/thealgorithms/sorts/MergeSort.java | 6 +++---
src/main/java/com/thealgorithms/sorts/TimSort.java | 5 ++---
4 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 45eceb0d..4ef8fe8d 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -5,9 +5,6 @@
-
-
-
diff --git a/src/main/java/com/thealgorithms/sorts/LinkListSort.java b/src/main/java/com/thealgorithms/sorts/LinkListSort.java
index e679fa9f..fb99439b 100644
--- a/src/main/java/com/thealgorithms/sorts/LinkListSort.java
+++ b/src/main/java/com/thealgorithms/sorts/LinkListSort.java
@@ -137,7 +137,7 @@ class Node {
class Task {
- static int[] a;
+ private int[] a;
public Node sortByMergeSort(Node head) {
if (head == null || head.next == null) return head;
@@ -245,7 +245,7 @@ class Task1 {
class Task2 {
- static int[] a;
+ private int[] a;
public Node sortByHeapSort(Node head) {
if (head == null || head.next == null) return head;
diff --git a/src/main/java/com/thealgorithms/sorts/MergeSort.java b/src/main/java/com/thealgorithms/sorts/MergeSort.java
index 0950b468..f4953e71 100644
--- a/src/main/java/com/thealgorithms/sorts/MergeSort.java
+++ b/src/main/java/com/thealgorithms/sorts/MergeSort.java
@@ -9,7 +9,7 @@ import static com.thealgorithms.sorts.SortUtils.less;
*/
class MergeSort implements SortAlgorithm {
- @SuppressWarnings("rawtypes") private static Comparable[] aux;
+ private Comparable[] aux;
/**
* Generic merge sort algorithm implements.
@@ -30,7 +30,7 @@ class MergeSort implements SortAlgorithm {
* @param left the first index of the array.
* @param right the last index of the array.
*/
- private static > void doSort(T[] arr, int left, int right) {
+ private > void doSort(T[] arr, int left, int right) {
if (left < right) {
int mid = (left + right) >>> 1;
doSort(arr, left, mid);
@@ -49,7 +49,7 @@ class MergeSort implements SortAlgorithm {
* increasing order.
*/
@SuppressWarnings("unchecked")
- private static > void merge(T[] arr, int left, int mid, int right) {
+ private > void merge(T[] arr, int left, int mid, int right) {
int i = left, j = mid + 1;
System.arraycopy(arr, left, aux, left, right + 1 - left);
diff --git a/src/main/java/com/thealgorithms/sorts/TimSort.java b/src/main/java/com/thealgorithms/sorts/TimSort.java
index be7eaa27..bb7ed8d5 100644
--- a/src/main/java/com/thealgorithms/sorts/TimSort.java
+++ b/src/main/java/com/thealgorithms/sorts/TimSort.java
@@ -9,7 +9,7 @@ import static com.thealgorithms.sorts.SortUtils.less;
*/
class TimSort implements SortAlgorithm {
private static final int SUB_ARRAY_SIZE = 32;
- @SuppressWarnings("rawtypes") private static Comparable[] aux;
+ private Comparable[] aux;
@Override
public > T[] sort(T[] a) {
@@ -30,8 +30,7 @@ class TimSort implements SortAlgorithm {
return a;
}
- @SuppressWarnings("unchecked")
- private static > void merge(T[] a, int lo, int mid, int hi) {
+ private > void merge(T[] a, int lo, int mid, int hi) {
int i = lo, j = mid + 1;
System.arraycopy(a, lo, aux, lo, hi + 1 - lo);