Skip to content

style: include SS_SHOULD_BE_STATIC #5198

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
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
3 changes: 0 additions & 3 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@
<Match>
<Bug pattern="UWF_UNWRITTEN_FIELD" />
</Match>
<Match>
<Bug pattern="SS_SHOULD_BE_STATIC" />
</Match>
<Match>
<Bug pattern="IT_NO_SUCH_ELEMENT" />
</Match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

// Hex [0-9],[A-F] -> Binary [0,1]
public class HexaDecimalToBinary {

private final int longBits = 8;

public String convert(String numHex) {
// String a HexaDecimal:
int conHex = Integer.parseInt(numHex, 16);
Expand All @@ -15,6 +12,7 @@ public String convert(String numHex) {
}

public String completeDigits(String binNum) {
final int longBits = 8;
for (int i = binNum.length(); i < longBits; i++) {
binNum = "0" + binNum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
*/
public class RedBlackBST {

private final int red = 0;
private final int black = 1;
private static final int RED = 0;
private static final int BLACK = 1;

private class Node {

int key = -1;
int color = black;
int color = BLACK;
Node left = nil;
Node right = nil;
Node p = nil;
Expand All @@ -31,15 +31,15 @@ public void printTree(Node node) {
return;
}
printTree(node.left);
System.out.print(((node.color == red) ? " R " : " B ") + "Key: " + node.key + " Parent: " + node.p.key + "\n");
System.out.print(((node.color == RED) ? " R " : " B ") + "Key: " + node.key + " Parent: " + node.p.key + "\n");
printTree(node.right);
}

public void printTreepre(Node node) {
if (node == nil) {
return;
}
System.out.print(((node.color == red) ? " R " : " B ") + "Key: " + node.key + " Parent: " + node.p.key + "\n");
System.out.print(((node.color == RED) ? " R " : " B ") + "Key: " + node.key + " Parent: " + node.p.key + "\n");
printTreepre(node.left);
printTreepre(node.right);
}
Expand All @@ -66,10 +66,10 @@ private void insert(Node node) {
Node temp = root;
if (root == nil) {
root = node;
node.color = black;
node.color = BLACK;
node.p = nil;
} else {
node.color = red;
node.color = RED;
while (true) {
if (node.key < temp.key) {
if (temp.left == nil) {
Expand All @@ -94,44 +94,44 @@ private void insert(Node node) {
}

private void fixTree(Node node) {
while (node.p.color == red) {
while (node.p.color == RED) {
Node y = nil;
if (node.p == node.p.p.left) {
y = node.p.p.right;

if (y != nil && y.color == red) {
node.p.color = black;
y.color = black;
node.p.p.color = red;
if (y != nil && y.color == RED) {
node.p.color = BLACK;
y.color = BLACK;
node.p.p.color = RED;
node = node.p.p;
continue;
}
if (node == node.p.right) {
node = node.p;
rotateLeft(node);
}
node.p.color = black;
node.p.p.color = red;
node.p.color = BLACK;
node.p.p.color = RED;
rotateRight(node.p.p);
} else {
y = node.p.p.left;
if (y != nil && y.color == red) {
node.p.color = black;
y.color = black;
node.p.p.color = red;
if (y != nil && y.color == RED) {
node.p.color = BLACK;
y.color = BLACK;
node.p.p.color = RED;
node = node.p.p;
continue;
}
if (node == node.p.left) {
node = node.p;
rotateRight(node);
}
node.p.color = black;
node.p.p.color = red;
node.p.color = BLACK;
node.p.p.color = RED;
rotateLeft(node.p.p);
}
}
root.color = black;
root.color = BLACK;
}

void rotateLeft(Node node) {
Expand Down Expand Up @@ -234,67 +234,67 @@ boolean delete(Node z) {
y.left.p = y;
y.color = z.color;
}
if (yorigcolor == black) {
if (yorigcolor == BLACK) {
deleteFixup(x);
}
return true;
}

void deleteFixup(Node x) {
while (x != root && x.color == black) {
while (x != root && x.color == BLACK) {
if (x == x.p.left) {
Node w = x.p.right;
if (w.color == red) {
w.color = black;
x.p.color = red;
if (w.color == RED) {
w.color = BLACK;
x.p.color = RED;
rotateLeft(x.p);
w = x.p.right;
}
if (w.left.color == black && w.right.color == black) {
w.color = red;
if (w.left.color == BLACK && w.right.color == BLACK) {
w.color = RED;
x = x.p;
continue;
} else if (w.right.color == black) {
w.left.color = black;
w.color = red;
} else if (w.right.color == BLACK) {
w.left.color = BLACK;
w.color = RED;
rotateRight(w);
w = x.p.right;
}
if (w.right.color == red) {
if (w.right.color == RED) {
w.color = x.p.color;
x.p.color = black;
w.right.color = black;
x.p.color = BLACK;
w.right.color = BLACK;
rotateLeft(x.p);
x = root;
}
} else {
Node w = x.p.left;
if (w.color == red) {
w.color = black;
x.p.color = red;
if (w.color == RED) {
w.color = BLACK;
x.p.color = RED;
rotateRight(x.p);
w = x.p.left;
}
if (w.right.color == black && w.left.color == black) {
w.color = red;
if (w.right.color == BLACK && w.left.color == BLACK) {
w.color = RED;
x = x.p;
continue;
} else if (w.left.color == black) {
w.right.color = black;
w.color = red;
} else if (w.left.color == BLACK) {
w.right.color = BLACK;
w.color = RED;
rotateLeft(w);
w = x.p.left;
}
if (w.left.color == red) {
if (w.left.color == RED) {
w.color = x.p.color;
x.p.color = black;
w.left.color = black;
x.p.color = BLACK;
w.left.color = BLACK;
rotateRight(x.p);
x = root;
}
}
}
x.color = black;
x.color = BLACK;
}

public void insertDemo() {
Expand Down