style: enable ArrayTypeStyle
in checkstyle (#5145)
This commit is contained in:
parent
414835db11
commit
bfb27eeb59
@ -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"/>
|
||||
|
@ -8,7 +8,7 @@ package com.thealgorithms.ciphers;
|
||||
public class DES {
|
||||
|
||||
private String key;
|
||||
private String subKeys[];
|
||||
private String[] subKeys;
|
||||
|
||||
private void sanitize(String key) {
|
||||
int length = key.length();
|
||||
@ -78,7 +78,7 @@ public class DES {
|
||||
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);
|
||||
|
||||
@ -159,7 +159,7 @@ public class DES {
|
||||
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++) {
|
||||
@ -184,8 +184,8 @@ public class DES {
|
||||
}
|
||||
|
||||
// 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];
|
||||
}
|
||||
@ -230,7 +230,7 @@ public class DES {
|
||||
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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test;
|
||||
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));
|
||||
@ -20,8 +20,8 @@ public class ActivitySelectionTest {
|
||||
|
||||
@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));
|
||||
@ -31,8 +31,8 @@ public class ActivitySelectionTest {
|
||||
|
||||
@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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user