Skip to content

Commit 5263ac1

Browse files
authored
Merge branch 'master' into add_test_for_CircleSort
2 parents 2f2d9aa + 032c288 commit 5263ac1

17 files changed

+160
-25
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ updates:
1010
directory: "/.github/workflows/"
1111
schedule:
1212
interval: "daily"
13+
14+
- package-ecosystem: "maven"
15+
directory: "/"
16+
schedule:
17+
interval: "daily"
1318
...

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ jobs:
3131
fail_ci_if_error: true
3232
- name: Checkstyle
3333
run: mvn checkstyle:check
34+
- name: SpotBugs
35+
run: mvn spotbugs:check

.gitpod.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM gitpod/workspace-java-17:2024-04-16-12-16-24
1+
FROM gitpod/workspace-java-17:2024-04-29-07-29-58
22

33
ENV LLVM_SCRIPT="tmp_llvm.sh"
44

checkstyle.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
<!-- Modifier Checks -->
149149
<!-- See https://checkstyle.org/checks/modifier/index.html -->
150-
<!-- TODO <module name="ModifierOrder"/> -->
150+
<module name="ModifierOrder"/>
151151
<!-- TODO <module name="RedundantModifier"/> -->
152152

153153
<!-- Checks for blocks. You know, those {}'s -->

pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<plugin>
7272
<groupId>org.apache.maven.plugins</groupId>
7373
<artifactId>maven-compiler-plugin</artifactId>
74-
<version>3.10.1</version>
74+
<version>3.13.0</version>
7575
<configuration>
7676
<source>17</source>
7777
<target>17</target>
@@ -110,10 +110,19 @@
110110
<dependency>
111111
<groupId>com.puppycrawl.tools</groupId>
112112
<artifactId>checkstyle</artifactId>
113-
<version>9.3</version>
113+
<version>10.16.0</version>
114114
</dependency>
115115
</dependencies>
116116
</plugin>
117+
<plugin>
118+
<groupId>com.github.spotbugs</groupId>
119+
<artifactId>spotbugs-maven-plugin</artifactId>
120+
<version>4.8.4.0</version>
121+
<configuration>
122+
<excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
123+
<includeTests>true</includeTests>
124+
</configuration>
125+
</plugin>
117126
</plugins>
118127
</build>
119128
</project>

spotbugs-exclude.xml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<FindBugsFilter>
2+
<Match>
3+
<Bug pattern="DM_DEFAULT_ENCODING" />
4+
</Match>
5+
<Match>
6+
<Bug pattern="EI_EXPOSE_REP2" />
7+
</Match>
8+
<Match>
9+
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
10+
</Match>
11+
<Match>
12+
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
13+
</Match>
14+
<Match>
15+
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE" />
16+
</Match>
17+
<Match>
18+
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
19+
</Match>
20+
<Match>
21+
<Bug pattern="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT" />
22+
</Match>
23+
<Match>
24+
<Bug pattern="DM_NEXTINT_VIA_NEXTDOUBLE" />
25+
</Match>
26+
<Match>
27+
<Bug pattern="NM_CLASS_NAMING_CONVENTION" />
28+
</Match>
29+
<Match>
30+
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC" />
31+
</Match>
32+
<Match>
33+
<Bug pattern="EI_EXPOSE_REP" />
34+
</Match>
35+
<Match>
36+
<Bug pattern="EI_EXPOSE_REP" />
37+
</Match>
38+
<Match>
39+
<Bug pattern="SBSC_USE_STRINGBUFFER_CONCATENATION" />
40+
</Match>
41+
<Match>
42+
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE" />
43+
</Match>
44+
<Match>
45+
<Bug pattern="MS_PKGPROTECT" />
46+
</Match>
47+
<Match>
48+
<Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE" />
49+
</Match>
50+
<Match>
51+
<Bug pattern="INT_BAD_REM_BY_1" />
52+
</Match>
53+
<Match>
54+
<Bug pattern="NM_METHOD_NAMING_CONVENTION" />
55+
</Match>
56+
<Match>
57+
<Bug pattern="ICAST_IDIV_CAST_TO_DOUBLE" />
58+
</Match>
59+
<Match>
60+
<Bug pattern="FE_FLOATING_POINT_EQUALITY" />
61+
</Match>
62+
<Match>
63+
<Bug pattern="CT_CONSTRUCTOR_THROW" />
64+
</Match>
65+
<Match>
66+
<Bug pattern="URF_UNREAD_FIELD" />
67+
</Match>
68+
<Match>
69+
<Bug pattern="RC_REF_COMPARISON" />
70+
</Match>
71+
<Match>
72+
<Bug pattern="MS_EXPOSE_REP" />
73+
</Match>
74+
<Match>
75+
<Bug pattern="IM_BAD_CHECK_FOR_ODD" />
76+
</Match>
77+
<Match>
78+
<Bug pattern="WMI_WRONG_MAP_ITERATOR" />
79+
</Match>
80+
<Match>
81+
<Bug pattern="DM_BOXED_PRIMITIVE_FOR_PARSING" />
82+
</Match>
83+
<Match>
84+
<Bug pattern="MS_SHOULD_BE_FINAL" />
85+
</Match>
86+
<Match>
87+
<Bug pattern="UWF_UNWRITTEN_FIELD" />
88+
</Match>
89+
<Match>
90+
<Bug pattern="SS_SHOULD_BE_STATIC" />
91+
</Match>
92+
<Match>
93+
<Bug pattern="HE_EQUALS_USE_HASHCODE" />
94+
</Match>
95+
<Match>
96+
<Bug pattern="IT_NO_SUCH_ELEMENT" />
97+
</Match>
98+
<Match>
99+
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
100+
</Match>
101+
<Match>
102+
<Bug pattern="UWF_NULL_FIELD" />
103+
</Match>
104+
<Match>
105+
<Bug pattern="NP_UNWRITTEN_FIELD" />
106+
</Match>
107+
<Match>
108+
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
109+
</Match>
110+
<Match>
111+
<Bug pattern="NP_IMMEDIATE_DEREFERENCE_OF_READLINE" />
112+
</Match>
113+
<Match>
114+
<Bug pattern="RV_RETURN_VALUE_IGNORED" />
115+
</Match>
116+
<Match>
117+
<Bug pattern="EQ_COMPARETO_USE_OBJECT_EQUALS" />
118+
</Match>
119+
<Match>
120+
<Bug pattern="SA_FIELD_SELF_ASSIGNMENT" />
121+
</Match>
122+
<Match>
123+
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
124+
</Match>
125+
<Match>
126+
<Bug pattern="RV_ABSOLUTE_VALUE_OF_HASHCODE" />
127+
</Match>
128+
</FindBugsFilter>

src/main/java/com/thealgorithms/bitmanipulation/HighestSetBit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public final class HighestSetBit {
1212
private HighestSetBit() {
1313
}
1414

15-
public final static Optional<Integer> findHighestSetBit(int num) {
15+
public static Optional<Integer> findHighestSetBit(int num) {
1616
if (num < 0) {
1717
throw new IllegalArgumentException("Input cannot be negative");
1818
}

src/main/java/com/thealgorithms/dynamicprogramming/LongestIncreasingSubsequence.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static int binarySearchBetween(int[] t, int end, int key) {
9797
return end + 1;
9898
}
9999
while (left < right - 1) {
100-
int middle = (left + right) / 2;
100+
final int middle = (left + right) >>> 1;
101101
if (t[middle] < key) {
102102
left = middle;
103103
} else {

src/main/java/com/thealgorithms/misc/RangeInSortedArray.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void alteredBinSearch(int[] nums, int key, int left, int right, in
2626
if (left > right) {
2727
return;
2828
}
29-
int mid = (left + right) / 2;
29+
int mid = (left + right) >>> 1;
3030
if (nums[mid] > key) {
3131
alteredBinSearch(nums, key, left, mid - 1, range, goLeft);
3232
} else if (nums[mid] < key) {
@@ -52,7 +52,7 @@ public static void alteredBinSearch(int[] nums, int key, int left, int right, in
5252
// of 'key'
5353
public static void alteredBinSearchIter(int[] nums, int key, int left, int right, int[] range, boolean goLeft) {
5454
while (left <= right) {
55-
int mid = (left + right) / 2;
55+
final int mid = (left + right) >>> 1;
5656
if (nums[mid] > key) {
5757
right = mid - 1;
5858
} else if (nums[mid] < key) {
@@ -84,7 +84,7 @@ public static int getCountLessThan(int[] nums, int key) {
8484
public static int getLessThan(int[] nums, int key, int left, int right) {
8585
int count = 0;
8686
while (left <= right) {
87-
int mid = (left + right) / 2;
87+
final int mid = (left + right) >>> 1;
8888
if (nums[mid] > key) {
8989
right = mid - 1;
9090
} else if (nums[mid] <= key) {

src/main/java/com/thealgorithms/others/CountWords.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @author Marcus
55
*/
6-
final public class CountWords {
6+
public final class CountWords {
77
private CountWords() {
88
}
99

src/main/java/com/thealgorithms/others/EulersFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @brief utility class for <a href="https://en.wikipedia.org/wiki/Euler%27s_totient_function">Euler's totient function</a>
55
*/
6-
final public class EulersFunction {
6+
public final class EulersFunction {
77
private EulersFunction() {
88
}
99

src/main/java/com/thealgorithms/others/LowestBasePalindrome.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @brief Class for finding the lowest base in which a given integer is a palindrome.
77
cf. https://oeis.org/A016026
88
*/
9-
final public class LowestBasePalindrome {
9+
public final class LowestBasePalindrome {
1010
private LowestBasePalindrome() {
1111
}
1212

src/main/java/com/thealgorithms/others/SieveOfEratosthenes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* @brief utility class implementing <a href="https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes</a>
77
*/
8-
final public class SieveOfEratosthenes {
8+
public final class SieveOfEratosthenes {
99
private SieveOfEratosthenes() {
1010
}
1111

src/main/java/com/thealgorithms/others/cn/HammingDistance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.thealgorithms.others.cn;
22

3-
final public class HammingDistance {
3+
public final class HammingDistance {
44
private HammingDistance() {
55
}
66

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public int[] binaryInsertSort(int[] array) {
1010
int high = i - 1;
1111

1212
while (low <= high) {
13-
int mid = (low + high) / 2;
13+
final int mid = (low + high) >>> 1;
1414
if (temp < array[mid]) {
1515
high = mid - 1;
1616
} else {

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.thealgorithms.sorts;
22

33
import java.util.ArrayList;
4-
import java.util.Arrays;
54
import java.util.List;
65

76
public class MergeSortRecursive {
@@ -59,11 +58,3 @@ private static List<Integer> sort(List<Integer> unsortedA, List<Integer> unsorte
5958
}
6059
}
6160
}
62-
63-
class App {
64-
65-
public static void main(String[] args) {
66-
MergeSortRecursive sort = new MergeSortRecursive(new ArrayList<>(Arrays.asList(4, 3, 1, 8, 5, 10, 0, 1, 4, 11, 8, 9)));
67-
sort.mergeSort();
68-
}
69-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private <T extends Comparable<T>> void sort(T[] array, int i, int j) {
1616
if (SortUtils.greaterOrEqual(i, j)) {
1717
return;
1818
}
19-
int m = (i + j) / 2;
19+
final int m = (i + j) >>> 1;
2020
sort(array, i, m);
2121
sort(array, m + 1, j);
2222
if (SortUtils.less(array[j], array[m])) {

0 commit comments

Comments
 (0)