style: include ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD (#5129)

This commit is contained in:
Piotr Idzik 2024-05-05 20:39:26 +02:00 committed by GitHub
parent 5d00889291
commit dc47e0aa42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 11 deletions

View File

@ -5,9 +5,6 @@
<Match>
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
</Match>
<Match>
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
</Match>

View File

@ -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;

View File

@ -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 <T extends Comparable<T>> void doSort(T[] arr, int left, int right) {
private <T extends Comparable<T>> 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 <T extends Comparable<T>> void merge(T[] arr, int left, int mid, int right) {
private <T extends Comparable<T>> 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);

View File

@ -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 extends Comparable<T>> T[] sort(T[] a) {
@ -30,8 +30,7 @@ class TimSort implements SortAlgorithm {
return a;
}
@SuppressWarnings("unchecked")
private static <T extends Comparable<T>> void merge(T[] a, int lo, int mid, int hi) {
private <T extends Comparable<T>> 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);