Skip to content

Commit 7fbf8f2

Browse files
committed
Removed code smells and followed naming convention
- Local variable names in java must be with the default regular expression ^[a-z][a-zA-Z0-9]*$ https://rules.sonarsource.com/java/tag/convention/RSPEC-117 - The diamond operator ("<>") should be used when the type of the maps are already defined https://rules.sonarsource.com/java/RSPEC-2293 - Package names being camel cased is a code smell
1 parent 56a527a commit 7fbf8f2

File tree

17 files changed

+27
-27
lines changed

17 files changed

+27
-27
lines changed

src/main/java/com/caching/LFUCache.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public void deleteNode(Node node) {
7575
public LFUCache(int capacity) {
7676
this.capacity = capacity;
7777
size = 0;
78-
freq = new TreeMap<Integer, DLL>();
79-
map = new HashMap<Integer, Node>();
78+
freq = new TreeMap<>();
79+
map = new HashMap<>();
8080
System.out.println("LFUCache initialised with capacity: " + capacity);
8181
}
8282

@@ -145,8 +145,8 @@ public void put(int key, T value) {
145145
dll.deleteNode(dll.tail.pre);
146146
if (dll.len == 0 && lowest != 1)
147147
freq.remove(lowest);
148-
DLL freq_one = freq.computeIfAbsent(1, k -> new DLL());
149-
freq_one.addToHead(node);
148+
DLL freqOne = freq.computeIfAbsent(1, k -> new DLL());
149+
freqOne.addToHead(node);
150150
}
151151
}
152152

src/main/java/com/ciphers/CaesarBruteForce.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ public class CaesarBruteForce {
55
/**
66
* Recursively Brute forces a parsed encrypted text, trying out all shifting keys from 1-26, printing out all decryption attempts
77
* @param message (String) The encrypted text.
8-
* @param Key (int) The key used to decrypt the encrypted text and is increment upon a recursive call.
8+
* @param key (int) The key used to decrypt the encrypted text and is increment upon a recursive call.
99
* @return (String) Concatenated string of all decryption attempts (For unit testing purposes).
1010
*/
11-
public String decrypt(String message, int Key) {
11+
public String decrypt(String message, int key) {
1212
final String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
13-
if (Key > 26){ System.out.println(); return null; }
13+
if (key > 26){ System.out.println(); return null; }
1414

1515
StringBuilder plainText = new StringBuilder();
1616
for (char character : message.toUpperCase().toCharArray()) {
1717
int index = LETTERS.indexOf(character);
1818

1919
if (index != -1) {
20-
index -= Key;
20+
index -= key;
2121
//Wrap around index value range[1-26]
2222
if (index < 0) { index += LETTERS.length(); }
2323
plainText.append(LETTERS.toCharArray()[index]);
2424
} else { plainText.append(character); }
2525
}
26-
System.out.println(String.format("Current Decryption Key %d : %s", Key, plainText));
27-
return plainText.append(decrypt(message, Key+1)).toString();
26+
System.out.println(String.format("Current Decryption Key %d : %s", key, plainText));
27+
return plainText.append(decrypt(message, key+1)).toString();
2828
}
2929
}

src/main/java/com/conversions/HexadecimalToBinary.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class HexadecimalToBinary {
1212
public String hexToBin (String hexStr) {
1313

1414
String binaryString = "", hexaNumbers = "0123456789ABCDEF",
15-
DecimalStr ="", binaryStringBefore ="" , binaryStringAfter = "";
15+
decimalStr ="", binaryStringBefore ="" , binaryStringAfter = "";
1616
int indexOfHex, decimalNumber = 0, k = 1, n =1, z=1, decimalNumberBefore = 0
1717
, decimalNumberAfter = 0;
1818
char letter;
@@ -48,12 +48,12 @@ public String hexToBin (String hexStr) {
4848

4949
String decimalNumberAfterStr = String.valueOf(decimalNumberAfter);
5050

51-
DecimalStr = decimalNumberBeforeStr + '.' + decimalNumberAfterStr;
51+
decimalStr = decimalNumberBeforeStr + '.' + decimalNumberAfterStr;
5252
}
5353

5454

5555

56-
int pointPositionDec = DecimalStr.indexOf(".");
56+
int pointPositionDec = decimalStr.indexOf(".");
5757
/**
5858
* Check whether the result contains a floating point or not
5959
*/

src/main/java/com/dataStructures/BinaryTree.java renamed to src/main/java/com/datastructures/BinaryTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dataStructures;
1+
package com.datastructures;
22

33
/**
44
* Binary tree for general value type, without redundancy

src/main/java/com/dataStructures/DisjointSet.java renamed to src/main/java/com/datastructures/DisjointSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dataStructures;
1+
package com.datastructures;
22

33
import java.io.Serializable;
44
import java.util.*;

src/main/java/com/dataStructures/GeneralQueue.java renamed to src/main/java/com/datastructures/GeneralQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dataStructures;
1+
package com.datastructures;
22

33
import com.types.Queue;
44

src/main/java/com/dataStructures/IntQueue.java renamed to src/main/java/com/datastructures/IntQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dataStructures;
1+
package com.datastructures;
22

33
/**
44
* This file contains an implementation of an integer only queue which is extremely quick and

src/main/java/com/dataStructures/SinglyLinkedList.java renamed to src/main/java/com/datastructures/SinglyLinkedList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dataStructures;
1+
package com.datastructures;
22

33

44

src/main/java/com/dataStructures/Stack.java renamed to src/main/java/com/datastructures/Stack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.dataStructures;
1+
package com.datastructures;
22

33
import java.io.Serializable;
44
import java.util.EmptyStackException;

src/main/java/com/matchings/stableMatching/GaleShapley.java renamed to src/main/java/com/matchings/stablematching/GaleShapley.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.matchings.stableMatching;
1+
package com.matchings.stablematching;
22

33
public class GaleShapley {
44

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy