Skip to content

Commit f06ef92

Browse files
style: enable StaticVariableName in checkstyle
1 parent 1607421 commit f06ef92

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
<!-- TODO <module name="MethodName"/> -->
116116
<module name="PackageName"/>
117117
<!-- TODO <module name="ParameterName"/> -->
118-
<!-- TODO <module name="StaticVariableName"/> -->
118+
<module name="StaticVariableName"/>
119119
<!-- TODO <module name="TypeName"/> -->
120120

121121
<!-- Checks for imports -->

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public void setKey(String key) {
3333
}
3434

3535
// Permutation table to convert initial 64 bit key to 56 bit key
36-
private static int[] PC1 = {57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4};
36+
private static int[] pc1 = {57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4};
3737

3838
// Lookup table used to shift the initial key, in order to generate the subkeys
39-
private static int[] KEY_SHIFTS = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
39+
private static int[] keyShifts = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1};
4040

4141
// Table to convert the 56 bit subkeys to 48 bit subkeys
42-
private static int[] PC2 = {14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32};
42+
private static int[] pc2 = {14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32};
4343

4444
// Initial permutatation of each 64 but message block
45-
private static int[] IP = {58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7};
45+
private static int[] ip = {58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7};
4646

4747
// Expansion table to convert right half of message blocks from 32 bits to 48 bits
4848
private static int[] expansion = {32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1};
@@ -70,33 +70,33 @@ public void setKey(String key) {
7070
static int[] permutation = {16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25};
7171

7272
// Table used for final inversion of the message box after 16 rounds of Feistel Function
73-
static int[] IPinverse = {40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25};
73+
static int[] ipInverse = {40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25};
7474

7575
private String[] getSubkeys(String originalKey) {
76-
StringBuilder permutedKey = new StringBuilder(); // Initial permutation of keys via PC1
76+
StringBuilder permutedKey = new StringBuilder(); // Initial permutation of keys via pc1
7777
int i, j;
7878
for (i = 0; i < 56; i++) {
79-
permutedKey.append(originalKey.charAt(PC1[i] - 1));
79+
permutedKey.append(originalKey.charAt(pc1[i] - 1));
8080
}
8181
String[] subKeys = new String[16];
8282
String initialPermutedKey = permutedKey.toString();
8383
String C0 = initialPermutedKey.substring(0, 28), D0 = initialPermutedKey.substring(28);
8484

8585
// We will now operate on the left and right halves of the permutedKey
8686
for (i = 0; i < 16; i++) {
87-
String Cn = C0.substring(KEY_SHIFTS[i]) + C0.substring(0, KEY_SHIFTS[i]);
88-
String Dn = D0.substring(KEY_SHIFTS[i]) + D0.substring(0, KEY_SHIFTS[i]);
87+
String Cn = C0.substring(keyShifts[i]) + C0.substring(0, keyShifts[i]);
88+
String Dn = D0.substring(keyShifts[i]) + D0.substring(0, keyShifts[i]);
8989
subKeys[i] = Cn + Dn;
9090
C0 = Cn; // Re-assign the values to create running permutation
9191
D0 = Dn;
9292
}
9393

94-
// Let us shrink the keys to 48 bits (well, characters here) using PC2
94+
// Let us shrink the keys to 48 bits (well, characters here) using pc2
9595
for (i = 0; i < 16; i++) {
9696
String key = subKeys[i];
9797
permutedKey.setLength(0);
9898
for (j = 0; j < 48; j++) {
99-
permutedKey.append(key.charAt(PC2[j] - 1));
99+
permutedKey.append(key.charAt(pc2[j] - 1));
100100
}
101101
subKeys[i] = permutedKey.toString();
102102
}
@@ -163,7 +163,7 @@ private String encryptBlock(String message, String[] keys) {
163163
StringBuilder permutedMessage = new StringBuilder();
164164
int i;
165165
for (i = 0; i < 64; i++) {
166-
permutedMessage.append(message.charAt(IP[i] - 1));
166+
permutedMessage.append(message.charAt(ip[i] - 1));
167167
}
168168
String L0 = permutedMessage.substring(0, 32), R0 = permutedMessage.substring(32);
169169

@@ -178,7 +178,7 @@ private String encryptBlock(String message, String[] keys) {
178178
String combinedBlock = R0 + L0; // Reverse the 16th block
179179
permutedMessage.setLength(0);
180180
for (i = 0; i < 64; i++) {
181-
permutedMessage.append(combinedBlock.charAt(IPinverse[i] - 1));
181+
permutedMessage.append(combinedBlock.charAt(ipInverse[i] - 1));
182182
}
183183
return permutedMessage.toString();
184184
}

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ private FordFulkerson() {
1010

1111
static final int INF = 987654321;
1212
// edges
13-
static int V;
13+
static int v;
1414
static int[][] capacity, flow;
1515

1616
public static void main(String[] args) {
1717
System.out.println("V : 6");
18-
V = 6;
19-
capacity = new int[V][V];
18+
v = 6;
19+
capacity = new int[v][v];
2020

2121
capacity[0][1] = 12;
2222
capacity[0][3] = 13;
@@ -32,11 +32,11 @@ public static void main(String[] args) {
3232
}
3333

3434
private static int networkFlow(int source, int sink) {
35-
flow = new int[V][V];
35+
flow = new int[v][v];
3636
int totalFlow = 0;
3737
while (true) {
38-
Vector<Integer> parent = new Vector<>(V);
39-
for (int i = 0; i < V; i++) {
38+
Vector<Integer> parent = new Vector<>(v);
39+
for (int i = 0; i < v; i++) {
4040
parent.add(-1);
4141
}
4242
Queue<Integer> q = new LinkedList<>();
@@ -45,7 +45,7 @@ private static int networkFlow(int source, int sink) {
4545
while (!q.isEmpty() && parent.get(sink) == -1) {
4646
int here = q.peek();
4747
q.poll();
48-
for (int there = 0; there < V; ++there) {
48+
for (int there = 0; there < v; ++there) {
4949
if (capacity[here][there] - flow[here][there] > 0 && parent.get(there) == -1) {
5050
q.add(there);
5151
parent.set(there, here);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public final class RabinKarp {
1111
private RabinKarp() {
1212
}
1313

14-
public static Scanner SCANNER = null;
14+
public static Scanner scanner = null;
1515
public static final int ALPHABET_SIZE = 256;
1616

1717
public static void main(String[] args) {
18-
SCANNER = new Scanner(System.in);
18+
scanner = new Scanner(System.in);
1919
System.out.println("Enter String");
20-
String text = SCANNER.nextLine();
20+
String text = scanner.nextLine();
2121
System.out.println("Enter pattern");
22-
String pattern = SCANNER.nextLine();
22+
String pattern = scanner.nextLine();
2323

2424
int q = 101;
2525
searchPat(text, pattern, q);

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ private StringMatchFiniteAutomata() {
1111
}
1212

1313
public static final int CHARS = 256;
14-
public static int[][] FA;
14+
public static int[][] fa;
1515
public static Scanner scanner = null;
1616

1717
public static void main(String[] args) {
@@ -30,13 +30,13 @@ public static void searchPat(String text, String pat) {
3030
int m = pat.length();
3131
int n = text.length();
3232

33-
FA = new int[m + 1][CHARS];
33+
fa = new int[m + 1][CHARS];
3434

35-
computeFA(pat, m, FA);
35+
computeFA(pat, m, fa);
3636

3737
int state = 0;
3838
for (int i = 0; i < n; i++) {
39-
state = FA[state][text.charAt(i)];
39+
state = fa[state][text.charAt(i)];
4040

4141
if (state == m) {
4242
System.out.println("Pattern found at index " + (i - m + 1));
@@ -45,10 +45,10 @@ public static void searchPat(String text, String pat) {
4545
}
4646

4747
// Computes finite automata for the partern
48-
public static void computeFA(String pat, int m, int[][] FA) {
48+
public static void computeFA(String pat, int m, int[][] fa) {
4949
for (int state = 0; state <= m; ++state) {
5050
for (int x = 0; x < CHARS; ++x) {
51-
FA[state][x] = getNextState(pat, m, state, x);
51+
fa[state][x] = getNextState(pat, m, state, x);
5252
}
5353
}
5454
}

0 commit comments

Comments
 (0)