Skip to content

Commit bfb27ee

Browse files
authored
style: enable ArrayTypeStyle in checkstyle (#5145)
1 parent 414835d commit bfb27ee

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181

182182
<!-- Miscellaneous other checks. -->
183183
<!-- See https://checkstyle.org/checks/misc/index.html -->
184-
<!-- TODO <module name="ArrayTypeStyle"/> -->
184+
<module name="ArrayTypeStyle"/>
185185
<!-- TODO <module name="FinalParameters"/> -->
186186
<!-- TODO <module name="TodoComment"/> -->
187187
<module name="UpperEll"/>

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class DES {
99

1010
private String key;
11-
private String subKeys[];
11+
private String[] subKeys;
1212

1313
private void sanitize(String key) {
1414
int length = key.length();
@@ -78,7 +78,7 @@ private String[] getSubkeys(String originalKey) {
7878
for (i = 0; i < 56; i++) {
7979
permutedKey.append(originalKey.charAt(PC1[i] - 1));
8080
}
81-
String subKeys[] = new String[16];
81+
String[] subKeys = new String[16];
8282
String initialPermutedKey = permutedKey.toString();
8383
String C0 = initialPermutedKey.substring(0, 28), D0 = initialPermutedKey.substring(28);
8484

@@ -159,7 +159,7 @@ private String feistel(String messageBlock, String key) {
159159
return permutedString.toString();
160160
}
161161

162-
private String encryptBlock(String message, String keys[]) {
162+
private String encryptBlock(String message, String[] keys) {
163163
StringBuilder permutedMessage = new StringBuilder();
164164
int i;
165165
for (i = 0; i < 64; i++) {
@@ -184,8 +184,8 @@ private String encryptBlock(String message, String keys[]) {
184184
}
185185

186186
// To decode, we follow the same process as encoding, but with reversed keys
187-
private String decryptBlock(String message, String keys[]) {
188-
String reversedKeys[] = new String[keys.length];
187+
private String decryptBlock(String message, String[] keys) {
188+
String[] reversedKeys = new String[keys.length];
189189
for (int i = 0; i < keys.length; i++) {
190190
reversedKeys[i] = keys[keys.length - i - 1];
191191
}
@@ -230,7 +230,7 @@ public String decrypt(String message) {
230230
for (i = 0; i < l; i += 64) {
231231
String block = message.substring(i, i + 64);
232232
String result = decryptBlock(block.toString(), subKeys);
233-
byte res[] = new byte[8];
233+
byte[] res = new byte[8];
234234
for (j = 0; j < 64; j += 8) {
235235
res[j / 8] = (byte) Integer.parseInt(result.substring(j, j + 8), 2);
236236
}

src/test/java/com/thealgorithms/bitmanipulation/NonRepeatingNumberFinderTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ class NonRepeatingNumberFinderTest {
1313

1414
@Test
1515
void testNonRepeatingNumberFinder() {
16-
int arr[] = {1, 2, 1, 2, 6};
16+
int[] arr = {1, 2, 1, 2, 6};
1717
assertEquals(6, NonRepeatingNumberFinder.findNonRepeatingNumber(arr));
18-
int arr1[] = {1, 2, 1, 2};
18+
int[] arr1 = {1, 2, 1, 2};
1919
assertEquals(0, NonRepeatingNumberFinder.findNonRepeatingNumber(arr1));
20-
int arr2[] = {12};
20+
int[] arr2 = {12};
2121
assertEquals(12, NonRepeatingNumberFinder.findNonRepeatingNumber(arr2));
2222
}
2323
}

src/test/java/com/thealgorithms/greedyalgorithms/ActivitySelectionTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
public class ActivitySelectionTest {
1010
@Test
1111
public void testActivitySelection() {
12-
int start[] = {1, 3, 0, 5, 8, 5};
13-
int end[] = {2, 4, 6, 7, 9, 9};
12+
int[] start = {1, 3, 0, 5, 8, 5};
13+
int[] end = {2, 4, 6, 7, 9, 9};
1414

1515
ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
1616
ArrayList<Integer> expected = new ArrayList<>(Arrays.asList(0, 1, 3, 4));
@@ -20,8 +20,8 @@ public void testActivitySelection() {
2020

2121
@Test
2222
public void testSingleActivity() {
23-
int start[] = {1};
24-
int end[] = {2};
23+
int[] start = {1};
24+
int[] end = {2};
2525

2626
ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
2727
ArrayList<Integer> expected = new ArrayList<>(Arrays.asList(0));
@@ -31,8 +31,8 @@ public void testSingleActivity() {
3131

3232
@Test
3333
public void testNoOverlap() {
34-
int start[] = {1, 2, 3};
35-
int end[] = {2, 3, 4};
34+
int[] start = {1, 2, 3};
35+
int[] end = {2, 3, 4};
3636

3737
ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
3838
ArrayList<Integer> expected = new ArrayList<>(Arrays.asList(0, 1, 2));

src/test/java/com/thealgorithms/greedyalgorithms/FractionalKnapsackTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@ public class FractionalKnapsackTest {
88

99
@Test
1010
public void testFractionalKnapsackWithExampleCase() {
11-
int weight[] = {10, 20, 30};
12-
int value[] = {60, 100, 120};
11+
int[] weight = {10, 20, 30};
12+
int[] value = {60, 100, 120};
1313
int capacity = 50;
1414
assertEquals(240, FractionalKnapsack.fractionalKnapsack(weight, value, capacity));
1515
}
1616

1717
@Test
1818
public void testFractionalKnapsackWithZeroCapacity() {
19-
int weight[] = {10, 20, 30};
20-
int value[] = {60, 100, 120};
19+
int[] weight = {10, 20, 30};
20+
int[] value = {60, 100, 120};
2121
int capacity = 0;
2222
assertEquals(0, FractionalKnapsack.fractionalKnapsack(weight, value, capacity));
2323
}
2424

2525
@Test
2626
public void testFractionalKnapsackWithEmptyItems() {
27-
int weight[] = {};
28-
int value[] = {};
27+
int[] weight = {};
28+
int[] value = {};
2929
int capacity = 50;
3030
assertEquals(0, FractionalKnapsack.fractionalKnapsack(weight, value, capacity));
3131
}

0 commit comments

Comments
 (0)