Skip to content

Commit f4a6ee5

Browse files
committed
Merge branch 'enable_LocalVariableName' of https://github.com/cpu-pixel/Java into enable_LocalVariableName
2 parents d2e9f05 + e0643f9 commit f4a6ee5

File tree

55 files changed

+223
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+223
-228
lines changed

.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-21:2024-05-15-13-36-34
1+
FROM gitpod/workspace-java-21:2024-05-27-17-11-15
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
@@ -112,7 +112,7 @@
112112
<module name="LocalFinalVariableName"/>
113113
<module name="LocalVariableName"/>
114114
<!-- TODO <module name="MemberName"/> -->
115-
<!-- TODO <module name="MethodName"/> -->
115+
<module name="MethodName"/>
116116
<module name="PackageName"/>
117117
<!-- TODO <module name="ParameterName"/> -->
118118
<module name="StaticVariableName"/>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<maven.compiler.source>21</maven.compiler.source>
1414
<maven.compiler.target>21</maven.compiler.target>
15-
<assertj.version>3.25.3</assertj.version>
15+
<assertj.version>3.26.0</assertj.version>
1616
</properties>
1717

1818
<dependencyManagement>
@@ -118,7 +118,7 @@
118118
<dependency>
119119
<groupId>com.puppycrawl.tools</groupId>
120120
<artifactId>checkstyle</artifactId>
121-
<version>10.16.0</version>
121+
<version>10.17.0</version>
122122
</dependency>
123123
</dependencies>
124124
</plugin>

spotbugs-exclude.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@
225225
<Match>
226226
<Bug pattern="ENMI_EQUALS_ON_ENUM" />
227227
</Match>
228-
<Match>
229-
<Bug pattern="NAB_NEEDLESS_BOXING_PARSE" />
230-
</Match>
231228
<Match>
232229
<Bug pattern="IMC_IMMATURE_CLASS_VAR_NAME" />
233230
</Match>
@@ -261,9 +258,6 @@
261258
<Match>
262259
<Bug pattern="SLS_SUSPICIOUS_LOOP_SEARCH" />
263260
</Match>
264-
<Match>
265-
<Bug pattern="SPP_TOSTRING_ON_STRING" />
266-
</Match>
267261
<!-- find-sec-bugs -->
268262
<Match>
269263
<Bug pattern="PREDICTABLE_RANDOM" />

src/main/java/com/thealgorithms/backtracking/PowerSum.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public class PowerSum {
1212
private int sum = 0;
1313

1414
public int powSum(int N, int X) {
15-
Sum(N, X, 1);
15+
sum(N, X, 1);
1616
return count;
1717
}
1818

1919
// here i is the natural number which will be raised by X and added in sum.
20-
public void Sum(int N, int X, int i) {
20+
public void sum(int N, int X, int i) {
2121
// if sum is equal to N that is one of our answer and count is increased.
2222
if (sum == N) {
2323
count++;
@@ -26,15 +26,15 @@ public void Sum(int N, int X, int i) {
2626
// result is less than N.
2727
else if (sum + power(i, X) <= N) {
2828
sum += power(i, X);
29-
Sum(N, X, i + 1);
29+
sum(N, X, i + 1);
3030
// backtracking and removing the number added last since no possible combination is
3131
// there with it.
3232
sum -= power(i, X);
3333
}
3434
if (power(i, X) < N) {
3535
// calling the sum function with next natural number after backtracking if when it is
3636
// raised to X is still less than X.
37-
Sum(N, X, i + 1);
37+
sum(N, X, i + 1);
3838
}
3939
}
4040

src/main/java/com/thealgorithms/ciphers/DES.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public String decrypt(String message) {
238238
}
239239
for (i = 0; i < l; i += 64) {
240240
String block = message.substring(i, i + 64);
241-
String result = decryptBlock(block.toString(), subKeys);
241+
String result = decryptBlock(block, subKeys);
242242
byte[] res = new byte[8];
243243
for (j = 0; j < 64; j += 8) {
244244
res[j / 8] = (byte) Integer.parseInt(result.substring(j, j + 8), 2);

src/main/java/com/thealgorithms/datastructures/heaps/LeftistHeap.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void insert(int a) {
9191
}
9292

9393
// Returns and removes the minimum element in the heap
94-
public int extract_min() {
94+
public int extractMin() {
9595
// If is empty return -1
9696
if (isEmpty()) return -1;
9797

@@ -101,17 +101,17 @@ public int extract_min() {
101101
}
102102

103103
// Function returning a list of an in order traversal of the data structure
104-
public ArrayList<Integer> in_order() {
104+
public ArrayList<Integer> inOrder() {
105105
ArrayList<Integer> lst = new ArrayList<>();
106-
in_order_aux(root, lst);
106+
inOrderAux(root, lst);
107107
return new ArrayList<>(lst);
108108
}
109109

110110
// Auxiliary function for in_order
111-
private void in_order_aux(Node n, ArrayList<Integer> lst) {
111+
private void inOrderAux(Node n, ArrayList<Integer> lst) {
112112
if (n == null) return;
113-
in_order_aux(n.left, lst);
113+
inOrderAux(n.left, lst);
114114
lst.add(n.element);
115-
in_order_aux(n.right, lst);
115+
inOrderAux(n.right, lst);
116116
}
117117
}

src/main/java/com/thealgorithms/datastructures/trees/GenericTree.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ private static final class Node {
2525
private final Node root;
2626
public GenericTree() { // Constructor
2727
Scanner scn = new Scanner(System.in);
28-
root = create_treeG(null, 0, scn);
28+
root = createTreeG(null, 0, scn);
2929
}
3030

31-
private Node create_treeG(Node node, int childIndex, Scanner scanner) {
31+
private Node createTreeG(Node node, int childIndex, Scanner scanner) {
3232
// display
3333
if (node == null) {
3434
System.out.println("Enter root's data");
@@ -41,7 +41,7 @@ private Node create_treeG(Node node, int childIndex, Scanner scanner) {
4141
System.out.println("number of children");
4242
int number = scanner.nextInt();
4343
for (int i = 0; i < number; i++) {
44-
Node child = create_treeG(node, i, scanner);
44+
Node child = createTreeG(node, i, scanner);
4545
node.child.add(child);
4646
}
4747
return node;
@@ -51,17 +51,17 @@ private Node create_treeG(Node node, int childIndex, Scanner scanner) {
5151
* Function to display the generic tree
5252
*/
5353
public void display() { // Helper function
54-
display_1(root);
54+
display1(root);
5555
}
5656

57-
private void display_1(Node parent) {
57+
private void display1(Node parent) {
5858
System.out.print(parent.data + "=>");
5959
for (int i = 0; i < parent.child.size(); i++) {
6060
System.out.print(parent.child.get(i).data + " ");
6161
}
6262
System.out.println(".");
6363
for (int i = 0; i < parent.child.size(); i++) {
64-
display_1(parent.child.get(i));
64+
display1(parent.child.get(i));
6565
}
6666
}
6767

src/main/java/com/thealgorithms/datastructures/trees/nearestRightKey.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ private NearestRightKey() {
88
}
99

1010
public static void main(String[] args) {
11-
NRKTree root = BuildTree();
11+
NRKTree root = buildTree();
1212
Scanner sc = new Scanner(System.in);
1313
System.out.print("Enter first number: ");
1414
int inputX0 = sc.nextInt();
@@ -17,7 +17,7 @@ public static void main(String[] args) {
1717
sc.close();
1818
}
1919

20-
public static NRKTree BuildTree() {
20+
public static NRKTree buildTree() {
2121
int randomX = ThreadLocalRandom.current().nextInt(0, 100 + 1);
2222
NRKTree root = new NRKTree(null, null, randomX);
2323

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public final class KadaneAlgorithm {
1010
private KadaneAlgorithm() {
1111
}
1212

13-
public static boolean max_Sum(int[] a, int predicted_answer) {
13+
public static boolean maxSum(int[] a, int predicted_answer) {
1414
int sum = a[0];
1515
int runningSum = 0;
1616
for (int k : a) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private LongestAlternatingSubsequence() {
1616
}
1717

1818
/* Function to return longest alternating subsequence length*/
19-
static int AlternatingLength(int[] arr, int n) {
19+
static int alternatingLength(int[] arr, int n) {
2020
/*
2121
2222
las[i][0] = Length of the longest
@@ -68,6 +68,6 @@ public static void main(String[] args) {
6868
int[] arr = {10, 22, 9, 33, 49, 50, 31, 60};
6969
int n = arr.length;
7070
System.out.println("Length of Longest "
71-
+ "alternating subsequence is " + AlternatingLength(arr, n));
71+
+ "alternating subsequence is " + alternatingLength(arr, n));
7272
}
7373
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public static void main(String[] args) {
1212
String a = "BBABCBCAB";
1313
String b = "BABCBAB";
1414

15-
String aLPS = LPS(a);
16-
String bLPS = LPS(b);
15+
String aLPS = lps(a);
16+
String bLPS = lps(b);
1717

1818
System.out.println(a + " => " + aLPS);
1919
System.out.println(b + " => " + bLPS);
2020
}
2121

22-
public static String LPS(String original) throws IllegalArgumentException {
22+
public static String lps(String original) throws IllegalArgumentException {
2323
StringBuilder reverse = new StringBuilder(original);
2424
reverse = reverse.reverse();
2525
return recursiveLPS(original, reverse.toString());

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ public static void main(String[] args) {
1111
String a = "babad";
1212
String b = "cbbd";
1313

14-
String aLPS = LPS(a);
15-
String bLPS = LPS(b);
14+
String aLPS = lps(a);
15+
String bLPS = lps(b);
1616

1717
System.out.println(a + " => " + aLPS);
1818
System.out.println(b + " => " + bLPS);
1919
}
2020

21-
private static String LPS(String input) {
21+
private static String lps(String input) {
2222
if (input == null || input.length() == 0) {
2323
return input;
2424
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public final class MatrixChainRecursiveTopDownMemoisation {
1010
private MatrixChainRecursiveTopDownMemoisation() {
1111
}
1212

13-
static int Memoized_Matrix_Chain(int[] p) {
13+
static int memoizedMatrixChain(int[] p) {
1414
int n = p.length;
1515
int[][] m = new int[n][n];
1616
for (int i = 0; i < n; i++) {
1717
for (int j = 0; j < n; j++) {
1818
m[i][j] = Integer.MAX_VALUE;
1919
}
2020
}
21-
return Lookup_Chain(m, p, 1, n - 1);
21+
return lookupChain(m, p, 1, n - 1);
2222
}
2323

24-
static int Lookup_Chain(int[][] m, int[] p, int i, int j) {
24+
static int lookupChain(int[][] m, int[] p, int i, int j) {
2525
if (i == j) {
2626
m[i][j] = 0;
2727
return m[i][j];
@@ -30,7 +30,7 @@ static int Lookup_Chain(int[][] m, int[] p, int i, int j) {
3030
return m[i][j];
3131
} else {
3232
for (int k = i; k < j; k++) {
33-
int q = Lookup_Chain(m, p, i, k) + Lookup_Chain(m, p, k + 1, j) + (p[i - 1] * p[k] * p[j]);
33+
int q = lookupChain(m, p, i, k) + lookupChain(m, p, k + 1, j) + (p[i - 1] * p[k] * p[j]);
3434
if (q < m[i][j]) {
3535
m[i][j] = q;
3636
}
@@ -43,6 +43,6 @@ static int Lookup_Chain(int[][] m, int[] p, int i, int j) {
4343
// respectively output should be Minimum number of multiplications is 38
4444
public static void main(String[] args) {
4545
int[] arr = {1, 2, 3, 4, 5};
46-
System.out.println("Minimum number of multiplications is " + Memoized_Matrix_Chain(arr));
46+
System.out.println("Minimum number of multiplications is " + memoizedMatrixChain(arr));
4747
}
4848
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ private WineProblem() {
1616

1717
// Method 1: Using Recursion
1818
// Time Complexity=0(2^N) Space Complexity=Recursion extra space
19-
public static int WPRecursion(int[] arr, int si, int ei) {
19+
public static int wpRecursion(int[] arr, int si, int ei) {
2020
int n = arr.length;
2121
int year = (n - (ei - si + 1)) + 1;
2222
if (si == ei) {
2323
return arr[si] * year;
2424
}
2525

26-
int start = WPRecursion(arr, si + 1, ei) + arr[si] * year;
27-
int end = WPRecursion(arr, si, ei - 1) + arr[ei] * year;
26+
int start = wpRecursion(arr, si + 1, ei) + arr[si] * year;
27+
int end = wpRecursion(arr, si, ei - 1) + arr[ei] * year;
2828

2929
return Math.max(start, end);
3030
}
3131

3232
// Method 2: Top-Down DP(Memoization)
3333
// Time Complexity=0(N*N) Space Complexity=0(N*N)+Recursion extra space
34-
public static int WPTD(int[] arr, int si, int ei, int[][] strg) {
34+
public static int wptd(int[] arr, int si, int ei, int[][] strg) {
3535
int n = arr.length;
3636
int year = (n - (ei - si + 1)) + 1;
3737
if (si == ei) {
@@ -41,8 +41,8 @@ public static int WPTD(int[] arr, int si, int ei, int[][] strg) {
4141
if (strg[si][ei] != 0) {
4242
return strg[si][ei];
4343
}
44-
int start = WPTD(arr, si + 1, ei, strg) + arr[si] * year;
45-
int end = WPTD(arr, si, ei - 1, strg) + arr[ei] * year;
44+
int start = wptd(arr, si + 1, ei, strg) + arr[si] * year;
45+
int end = wptd(arr, si, ei - 1, strg) + arr[ei] * year;
4646

4747
int ans = Math.max(start, end);
4848

@@ -53,7 +53,7 @@ public static int WPTD(int[] arr, int si, int ei, int[][] strg) {
5353

5454
// Method 3: Bottom-Up DP(Tabulation)
5555
// Time Complexity=0(N*N/2)->0(N*N) Space Complexity=0(N*N)
56-
public static int WPBU(int[] arr) {
56+
public static int wpbu(int[] arr) {
5757
int n = arr.length;
5858
int[][] strg = new int[n][n];
5959

@@ -76,9 +76,9 @@ public static int WPBU(int[] arr) {
7676

7777
public static void main(String[] args) {
7878
int[] arr = {2, 3, 5, 1, 4};
79-
System.out.println("Method 1: " + WPRecursion(arr, 0, arr.length - 1));
80-
System.out.println("Method 2: " + WPTD(arr, 0, arr.length - 1, new int[arr.length][arr.length]));
81-
System.out.println("Method 3: " + WPBU(arr));
79+
System.out.println("Method 1: " + wpRecursion(arr, 0, arr.length - 1));
80+
System.out.println("Method 2: " + wptd(arr, 0, arr.length - 1, new int[arr.length][arr.length]));
81+
System.out.println("Method 3: " + wpbu(arr));
8282
}
8383
}
8484
// Memoization vs Tabulation : https://www.geeksforgeeks.org/tabulation-vs-memoization/

src/main/java/com/thealgorithms/maths/HarshadNumber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static boolean isHarshad(long n) {
3434
* {@code false}
3535
*/
3636
public static boolean isHarshad(String s) {
37-
long n = Long.valueOf(s);
37+
final Long n = Long.valueOf(s);
3838
if (n <= 0) return false;
3939

4040
int sumOfDigits = 0;

src/main/java/com/thealgorithms/maths/SquareRootWithBabylonianMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ private SquareRootWithBabylonianMethod() {
1010
* @param num contains elements
1111
* @return the square root of num
1212
*/
13-
public static float square_Root(float num) {
13+
public static float squareRoot(float num) {
1414
float a = num;
1515
float b = 1;
1616
double e = 0.000001;

src/main/java/com/thealgorithms/maths/TrinomialTriangle.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public final class TrinomialTriangle {
1111
private TrinomialTriangle() {
1212
}
1313

14-
public static int TrinomialValue(int n, int k) {
14+
public static int trinomialValue(int n, int k) {
1515
if (n == 0 && k == 0) {
1616
return 1;
1717
}
@@ -20,17 +20,17 @@ public static int TrinomialValue(int n, int k) {
2020
return 0;
2121
}
2222

23-
return (TrinomialValue(n - 1, k - 1) + TrinomialValue(n - 1, k) + TrinomialValue(n - 1, k + 1));
23+
return (trinomialValue(n - 1, k - 1) + trinomialValue(n - 1, k) + trinomialValue(n - 1, k + 1));
2424
}
2525

2626
public static void printTrinomial(int n) {
2727
for (int i = 0; i < n; i++) {
2828
for (int j = -i; j <= 0; j++) {
29-
System.out.print(TrinomialValue(i, j) + " ");
29+
System.out.print(trinomialValue(i, j) + " ");
3030
}
3131

3232
for (int j = 1; j <= i; j++) {
33-
System.out.print(TrinomialValue(i, j) + " ");
33+
System.out.print(trinomialValue(i, j) + " ");
3434
}
3535

3636
System.out.println();

0 commit comments

Comments
 (0)