Skip to content

style: enable ArrayTypeStyle in checkstyle #5145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@

<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/checks/misc/index.html -->
<!-- TODO <module name="ArrayTypeStyle"/> -->
<module name="ArrayTypeStyle"/>
<!-- TODO <module name="FinalParameters"/> -->
<!-- TODO <module name="TodoComment"/> -->
<module name="UpperEll"/>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/thealgorithms/ciphers/DES.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public class DES {

private String key;
private String subKeys[];
private String[] subKeys;

private void sanitize(String key) {
int length = key.length();
Expand Down Expand Up @@ -78,7 +78,7 @@ private String[] getSubkeys(String originalKey) {
for (i = 0; i < 56; i++) {
permutedKey.append(originalKey.charAt(PC1[i] - 1));
}
String subKeys[] = new String[16];
String[] subKeys = new String[16];
String initialPermutedKey = permutedKey.toString();
String C0 = initialPermutedKey.substring(0, 28), D0 = initialPermutedKey.substring(28);

Expand Down Expand Up @@ -159,7 +159,7 @@ private String feistel(String messageBlock, String key) {
return permutedString.toString();
}

private String encryptBlock(String message, String keys[]) {
private String encryptBlock(String message, String[] keys) {
StringBuilder permutedMessage = new StringBuilder();
int i;
for (i = 0; i < 64; i++) {
Expand All @@ -184,8 +184,8 @@ private String encryptBlock(String message, String keys[]) {
}

// To decode, we follow the same process as encoding, but with reversed keys
private String decryptBlock(String message, String keys[]) {
String reversedKeys[] = new String[keys.length];
private String decryptBlock(String message, String[] keys) {
String[] reversedKeys = new String[keys.length];
for (int i = 0; i < keys.length; i++) {
reversedKeys[i] = keys[keys.length - i - 1];
}
Expand Down Expand Up @@ -230,7 +230,7 @@ public String decrypt(String message) {
for (i = 0; i < l; i += 64) {
String block = message.substring(i, i + 64);
String result = decryptBlock(block.toString(), subKeys);
byte res[] = new byte[8];
byte[] res = new byte[8];
for (j = 0; j < 64; j += 8) {
res[j / 8] = (byte) Integer.parseInt(result.substring(j, j + 8), 2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class NonRepeatingNumberFinderTest {

@Test
void testNonRepeatingNumberFinder() {
int arr[] = {1, 2, 1, 2, 6};
int[] arr = {1, 2, 1, 2, 6};
assertEquals(6, NonRepeatingNumberFinder.findNonRepeatingNumber(arr));
int arr1[] = {1, 2, 1, 2};
int[] arr1 = {1, 2, 1, 2};
assertEquals(0, NonRepeatingNumberFinder.findNonRepeatingNumber(arr1));
int arr2[] = {12};
int[] arr2 = {12};
assertEquals(12, NonRepeatingNumberFinder.findNonRepeatingNumber(arr2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
public class ActivitySelectionTest {
@Test
public void testActivitySelection() {
int start[] = {1, 3, 0, 5, 8, 5};
int end[] = {2, 4, 6, 7, 9, 9};
int[] start = {1, 3, 0, 5, 8, 5};
int[] end = {2, 4, 6, 7, 9, 9};

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

@Test
public void testSingleActivity() {
int start[] = {1};
int end[] = {2};
int[] start = {1};
int[] end = {2};

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

@Test
public void testNoOverlap() {
int start[] = {1, 2, 3};
int end[] = {2, 3, 4};
int[] start = {1, 2, 3};
int[] end = {2, 3, 4};

ArrayList<Integer> result = ActivitySelection.activitySelection(start, end);
ArrayList<Integer> expected = new ArrayList<>(Arrays.asList(0, 1, 2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ public class FractionalKnapsackTest {

@Test
public void testFractionalKnapsackWithExampleCase() {
int weight[] = {10, 20, 30};
int value[] = {60, 100, 120};
int[] weight = {10, 20, 30};
int[] value = {60, 100, 120};
int capacity = 50;
assertEquals(240, FractionalKnapsack.fractionalKnapsack(weight, value, capacity));
}

@Test
public void testFractionalKnapsackWithZeroCapacity() {
int weight[] = {10, 20, 30};
int value[] = {60, 100, 120};
int[] weight = {10, 20, 30};
int[] value = {60, 100, 120};
int capacity = 0;
assertEquals(0, FractionalKnapsack.fractionalKnapsack(weight, value, capacity));
}

@Test
public void testFractionalKnapsackWithEmptyItems() {
int weight[] = {};
int value[] = {};
int[] weight = {};
int[] value = {};
int capacity = 50;
assertEquals(0, FractionalKnapsack.fractionalKnapsack(weight, value, capacity));
}
Expand Down