Skip to content

Commit a6e873d

Browse files
cpu-pixelvil02
andauthored
style: enable MemberName in checkstyle (#5193)
* style: enable MemberName in checkstyle * style: simply uncomment `MemberName` --------- Co-authored-by: Piotr Idzik <[email protected]>
1 parent d2bfb10 commit a6e873d

17 files changed

+168
-168
lines changed

checkstyle.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<module name="ConstantName"/>
112112
<module name="LocalFinalVariableName"/>
113113
<module name="LocalVariableName"/>
114-
<!-- TODO <module name="MemberName"/> -->
114+
<module name="MemberName"/>
115115
<module name="MethodName"/>
116116
<module name="PackageName"/>
117117
<!-- TODO <module name="ParameterName"/> -->

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class Blowfish {
1212

1313
// Initializing substitution boxes
14-
String[][] S = {
14+
String[][] sBox = {
1515
{
1616
"d1310ba6",
1717
"98dfb5ac",
@@ -1047,7 +1047,7 @@ public class Blowfish {
10471047
};
10481048

10491049
// Initializing subkeys with digits of pi
1050-
String[] P = {
1050+
String[] subKeys = {
10511051
"243f6a88",
10521052
"85a308d3",
10531053
"13198a2e",
@@ -1154,7 +1154,7 @@ private String f(String plainText) {
11541154
for (int i = 0; i < 8; i += 2) {
11551155
// column number for S-box is a 8-bit value
11561156
long col = Long.parseUnsignedLong(hexToBin(plainText.substring(i, i + 2)), 2);
1157-
a[i / 2] = S[i / 2][(int) col];
1157+
a[i / 2] = sBox[i / 2][(int) col];
11581158
}
11591159
ans = addBin(a[0], a[1]);
11601160
ans = xor(ans, a[2]);
@@ -1165,9 +1165,9 @@ private String f(String plainText) {
11651165
// generate subkeys
11661166
private void keyGenerate(String key) {
11671167
int j = 0;
1168-
for (int i = 0; i < P.length; i++) {
1168+
for (int i = 0; i < subKeys.length; i++) {
11691169
// XOR-ing 32-bit parts of the key with initial subkeys
1170-
P[i] = xor(P[i], key.substring(j, j + 8));
1170+
subKeys[i] = xor(subKeys[i], key.substring(j, j + 8));
11711171

11721172
j = (j + 8) % key.length();
11731173
}
@@ -1179,7 +1179,7 @@ private String round(int time, String plainText) {
11791179
String right;
11801180
left = plainText.substring(0, 8);
11811181
right = plainText.substring(8, 16);
1182-
left = xor(left, P[time]);
1182+
left = xor(left, subKeys[time]);
11831183

11841184
// output from F function
11851185
String fOut = f(left);
@@ -1207,8 +1207,8 @@ String encrypt(String plainText, String key) {
12071207
// postprocessing
12081208
String right = plainText.substring(0, 8);
12091209
String left = plainText.substring(8, 16);
1210-
right = xor(right, P[16]);
1211-
left = xor(left, P[17]);
1210+
right = xor(right, subKeys[16]);
1211+
left = xor(left, subKeys[17]);
12121212
return left + right;
12131213
}
12141214

@@ -1229,8 +1229,8 @@ String decrypt(String cipherText, String key) {
12291229
// postprocessing
12301230
String right = cipherText.substring(0, 8);
12311231
String left = cipherText.substring(8, 16);
1232-
right = xor(right, P[1]);
1233-
left = xor(left, P[0]);
1232+
right = xor(right, subKeys[1]);
1233+
left = xor(left, subKeys[0]);
12341234
return left + right;
12351235
}
12361236
}

src/main/java/com/thealgorithms/conversions/HexaDecimalToBinary.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Hex [0-9],[A-F] -> Binary [0,1]
44
public class HexaDecimalToBinary {
55

6-
private final int LONG_BITS = 8;
6+
private final int longBits = 8;
77

88
public String convert(String numHex) {
99
// String a HexaDecimal:
@@ -15,7 +15,7 @@ public String convert(String numHex) {
1515
}
1616

1717
public String completeDigits(String binNum) {
18-
for (int i = binNum.length(); i < LONG_BITS; i++) {
18+
for (int i = binNum.length(); i < longBits; i++) {
1919
binNum = "0" + binNum;
2020
}
2121
return binNum;

src/main/java/com/thealgorithms/datastructures/crdt/GCounter.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818

1919
class GCounter {
20-
private final Map<Integer, Integer> P;
20+
private final Map<Integer, Integer> counterMap;
2121
private final int myId;
2222
private final int n;
2323

@@ -29,18 +29,18 @@ class GCounter {
2929
GCounter(int myId, int n) {
3030
this.myId = myId;
3131
this.n = n;
32-
this.P = new HashMap<>();
32+
this.counterMap = new HashMap<>();
3333

3434
for (int i = 0; i < n; i++) {
35-
P.put(i, 0);
35+
counterMap.put(i, 0);
3636
}
3737
}
3838

3939
/**
4040
* Increments the counter for the current node.
4141
*/
4242
public void increment() {
43-
P.put(myId, P.get(myId) + 1);
43+
counterMap.put(myId, counterMap.get(myId) + 1);
4444
}
4545

4646
/**
@@ -50,7 +50,7 @@ public void increment() {
5050
*/
5151
public int value() {
5252
int sum = 0;
53-
for (int v : P.values()) {
53+
for (int v : counterMap.values()) {
5454
sum += v;
5555
}
5656
return sum;
@@ -64,7 +64,7 @@ public int value() {
6464
*/
6565
public boolean compare(GCounter other) {
6666
for (int i = 0; i < n; i++) {
67-
if (this.P.get(i) > other.P.get(i)) {
67+
if (this.counterMap.get(i) > other.counterMap.get(i)) {
6868
return false;
6969
}
7070
}
@@ -78,7 +78,7 @@ public boolean compare(GCounter other) {
7878
*/
7979
public void merge(GCounter other) {
8080
for (int i = 0; i < n; i++) {
81-
this.P.put(i, Math.max(this.P.get(i), other.P.get(i)));
81+
this.counterMap.put(i, Math.max(this.counterMap.get(i), other.counterMap.get(i)));
8282
}
8383
}
8484
}

src/main/java/com/thealgorithms/datastructures/crdt/PNCounter.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818

1919
class PNCounter {
20-
private final Map<Integer, Integer> P;
21-
private final Map<Integer, Integer> N;
20+
private final Map<Integer, Integer> pCounter;
21+
private final Map<Integer, Integer> nCounter;
2222
private final int myId;
2323
private final int n;
2424

@@ -31,27 +31,27 @@ class PNCounter {
3131
PNCounter(int myId, int n) {
3232
this.myId = myId;
3333
this.n = n;
34-
this.P = new HashMap<>();
35-
this.N = new HashMap<>();
34+
this.pCounter = new HashMap<>();
35+
this.nCounter = new HashMap<>();
3636

3737
for (int i = 0; i < n; i++) {
38-
P.put(i, 0);
39-
N.put(i, 0);
38+
pCounter.put(i, 0);
39+
nCounter.put(i, 0);
4040
}
4141
}
4242

4343
/**
4444
* Increments the increment counter for the current node.
4545
*/
4646
public void increment() {
47-
P.put(myId, P.get(myId) + 1);
47+
pCounter.put(myId, pCounter.get(myId) + 1);
4848
}
4949

5050
/**
5151
* Increments the decrement counter for the current node.
5252
*/
5353
public void decrement() {
54-
N.put(myId, N.get(myId) + 1);
54+
nCounter.put(myId, nCounter.get(myId) + 1);
5555
}
5656

5757
/**
@@ -60,8 +60,8 @@ public void decrement() {
6060
* @return The total value of the counter.
6161
*/
6262
public int value() {
63-
int sumP = P.values().stream().mapToInt(Integer::intValue).sum();
64-
int sumN = N.values().stream().mapToInt(Integer::intValue).sum();
63+
int sumP = pCounter.values().stream().mapToInt(Integer::intValue).sum();
64+
int sumN = nCounter.values().stream().mapToInt(Integer::intValue).sum();
6565
return sumP - sumN;
6666
}
6767

@@ -76,7 +76,7 @@ public boolean compare(PNCounter other) {
7676
throw new IllegalArgumentException("Cannot compare PN-Counters with different number of nodes");
7777
}
7878
for (int i = 0; i < n; i++) {
79-
if (this.P.get(i) > other.P.get(i) && this.N.get(i) > other.N.get(i)) {
79+
if (this.pCounter.get(i) > other.pCounter.get(i) && this.nCounter.get(i) > other.nCounter.get(i)) {
8080
return false;
8181
}
8282
}
@@ -93,8 +93,8 @@ public void merge(PNCounter other) {
9393
throw new IllegalArgumentException("Cannot merge PN-Counters with different number of nodes");
9494
}
9595
for (int i = 0; i < n; i++) {
96-
this.P.put(i, Math.max(this.P.get(i), other.P.get(i)));
97-
this.N.put(i, Math.max(this.N.get(i), other.N.get(i)));
96+
this.pCounter.put(i, Math.max(this.pCounter.get(i), other.pCounter.get(i)));
97+
this.nCounter.put(i, Math.max(this.nCounter.get(i), other.nCounter.get(i)));
9898
}
9999
}
100100
}

src/main/java/com/thealgorithms/datastructures/graphs/FloydWarshall.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
public class FloydWarshall {
66

7-
private int[][] DistanceMatrix;
7+
private int[][] distanceMatrix;
88
private int numberofvertices; // number of vertices in the graph
99
public static final int INFINITY = 999;
1010

1111
public FloydWarshall(int numberofvertices) {
12-
DistanceMatrix = new int[numberofvertices + 1][numberofvertices + 1]; // stores the value of distance from all the possible path form the source
12+
distanceMatrix = new int[numberofvertices + 1][numberofvertices + 1]; // stores the value of distance from all the possible path form the source
1313
// vertex to destination vertex
1414
// The matrix is initialized with 0's by default
1515
this.numberofvertices = numberofvertices;
@@ -18,17 +18,17 @@ public FloydWarshall(int numberofvertices) {
1818
public void floydwarshall(int[][] AdjacencyMatrix) { // calculates all the distances from source to destination vertex
1919
for (int source = 1; source <= numberofvertices; source++) {
2020
for (int destination = 1; destination <= numberofvertices; destination++) {
21-
DistanceMatrix[source][destination] = AdjacencyMatrix[source][destination];
21+
distanceMatrix[source][destination] = AdjacencyMatrix[source][destination];
2222
}
2323
}
2424
for (int intermediate = 1; intermediate <= numberofvertices; intermediate++) {
2525
for (int source = 1; source <= numberofvertices; source++) {
2626
for (int destination = 1; destination <= numberofvertices; destination++) {
27-
if (DistanceMatrix[source][intermediate] + DistanceMatrix[intermediate][destination] < DistanceMatrix[source][destination]) { // calculated distance it get replaced as
27+
if (distanceMatrix[source][intermediate] + distanceMatrix[intermediate][destination] < distanceMatrix[source][destination]) { // calculated distance it get replaced as
2828
// new shortest distance // if the new
2929
// distance calculated is less then the
3030
// earlier shortest
31-
DistanceMatrix[source][destination] = DistanceMatrix[source][intermediate] + DistanceMatrix[intermediate][destination];
31+
distanceMatrix[source][destination] = distanceMatrix[source][intermediate] + distanceMatrix[intermediate][destination];
3232
}
3333
}
3434
}
@@ -40,7 +40,7 @@ public void floydwarshall(int[][] AdjacencyMatrix) { // calculates all the dista
4040
for (int source = 1; source <= numberofvertices; source++) {
4141
System.out.print(source + "\t");
4242
for (int destination = 1; destination <= numberofvertices; destination++) {
43-
System.out.print(DistanceMatrix[source][destination] + "\t");
43+
System.out.print(distanceMatrix[source][destination] + "\t");
4444
}
4545
System.out.println();
4646
}

src/main/java/com/thealgorithms/datastructures/graphs/HamiltonianCycle.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
public class HamiltonianCycle {
1010

11-
private int V;
11+
private int vertex;
1212
private int pathCount;
1313
private int[] cycle;
1414
private int[][] graph;
@@ -22,8 +22,8 @@ public class HamiltonianCycle {
2222
* else returns 1D array with value -1.
2323
*/
2424
public int[] findHamiltonianCycle(int[][] graph) {
25-
this.V = graph.length;
26-
this.cycle = new int[this.V + 1];
25+
this.vertex = graph.length;
26+
this.cycle = new int[this.vertex + 1];
2727

2828
// Initialize path array with -1 value
2929
for (int i = 0; i < this.cycle.length; i++) {
@@ -53,17 +53,17 @@ public int[] findHamiltonianCycle(int[][] graph) {
5353
* @returns true if path is found false otherwise
5454
*/
5555
public boolean isPathFound(int vertex) {
56-
boolean isLastVertexConnectedToStart = this.graph[vertex][0] == 1 && this.pathCount == this.V;
56+
boolean isLastVertexConnectedToStart = this.graph[vertex][0] == 1 && this.pathCount == this.vertex;
5757
if (isLastVertexConnectedToStart) {
5858
return true;
5959
}
6060

6161
/** all vertices selected but last vertex not linked to 0 **/
62-
if (this.pathCount == this.V) {
62+
if (this.pathCount == this.vertex) {
6363
return false;
6464
}
6565

66-
for (int v = 0; v < this.V; v++) {
66+
for (int v = 0; v < this.vertex; v++) {
6767
/** if connected **/
6868
if (this.graph[vertex][v] == 1) {
6969
/** add to path **/

0 commit comments

Comments
 (0)