Skip to content

Commit

Permalink
refactor: Enum values should be compared with "=="
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek and TeamModerne committed Dec 24, 2024
1 parent 8861133 commit 9472d86
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,12 @@ public J.If.Else visitElse(J.If.Else else_, P p) {

@Override
public J.Binary visitBinary(J.Binary binary, P p) {
if (J.Binary.Type.And.equals(binary.getOperator())) {
if (J.Binary.Type.And == binary.getOperator()) {
ControlFlowAnalysis<P> left = visitRecursive(current, binary.getLeft(), p);
Set<ControlFlowNode.ConditionNode> conditionNodes = allAsConditionNodesMissingTruthFirst(left.current);
ControlFlowAnalysis<P> right = visitRecursive(conditionNodes, binary.getRight(), p);
current = Stream.concat(right.current.stream(), Stream.of(getControlFlowNodeMissingOneSuccessor(conditionNodes))).collect(Collectors.toSet());
} else if (J.Binary.Type.Or.equals(binary.getOperator())) {
} else if (J.Binary.Type.Or == binary.getOperator()) {
ControlFlowAnalysis<P> left = visitRecursive(current, binary.getLeft(), p);
Set<ControlFlowNode.ConditionNode> conditionNodes = allAsConditionNodesMissingFalseFirst(left.current);
ControlFlowAnalysis<P> right = visitRecursive(conditionNodes, binary.getRight(), p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ static final class End extends ControlFlowNode implements GraphTerminator {

@Override
Set<ControlFlowNode> getSuccessors() {
if (GraphType.LAMBDA.equals(graphType)) {
if (GraphType.LAMBDA == graphType) {
if (successor == null) {
throw new ControlFlowIllegalStateException(exceptionMessageBuilder("Lambda End node has no successor").thisNode(this).addPredecessors(this));
}
Expand All @@ -487,7 +487,7 @@ Set<ControlFlowNode> getSuccessors() {

@Override
protected void _addSuccessorInternal(ControlFlowNode successor) {
if (GraphType.LAMBDA.equals(graphType)) {
if (GraphType.LAMBDA == graphType) {
if (this.successor != null) {
throw new ControlFlowIllegalStateException(exceptionMessageBuilder("Lambda End node already has a successor").thisNode(this).current(this.successor).otherNode(successor));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public String visualizeAsDotfile(String name, boolean darkMode, ControlFlowSumma
abstractToVisualNodeMapping.put(node, i);
if (node instanceof ControlFlowNode.GraphTerminator) {
ControlFlowNode.GraphTerminator terminator = (ControlFlowNode.GraphTerminator) node;
if (terminator.getGraphType().equals(ControlFlowNode.GraphType.METHOD_BODY_OR_STATIC_INITIALIZER_OR_INSTANCE_INITIALIZER)) {
if (terminator.getGraphType() == ControlFlowNode.GraphType.METHOD_BODY_OR_STATIC_INITIALIZER_OR_INSTANCE_INITIALIZER) {
if (node instanceof ControlFlowNode.Start) {
vizSrc = i;
} else if (node instanceof ControlFlowNode.End) {
Expand Down Expand Up @@ -165,7 +165,7 @@ private int comparingType() {
private static String getShape(ControlFlowNode node) {
if (node instanceof ControlFlowNode.Start || node instanceof ControlFlowNode.End) {
ControlFlowNode.GraphTerminator graphTerminator = (ControlFlowNode.GraphTerminator) node;
if (ControlFlowNode.GraphType.METHOD_BODY_OR_STATIC_INITIALIZER_OR_INSTANCE_INITIALIZER.equals(graphTerminator.getGraphType())) {
if (ControlFlowNode.GraphType.METHOD_BODY_OR_STATIC_INITIALIZER_OR_INSTANCE_INITIALIZER == graphTerminator.getGraphType()) {
return "circle";
} else {
return "oval";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static boolean isStringAddTaintStep(
) {
return sinkNode
.asExpr(BinaryExpr.class)
.bind(srcNode.asExpr(), binary -> src -> J.Binary.Type.Addition.equals(binary.getOperator()) &&
.bind(srcNode.asExpr(), binary -> src -> J.Binary.Type.Addition == binary.getOperator() &&
binary.getLeft().equals(src) || binary.getRight().equals(src))
.orSome(false);
}
Expand Down

0 comments on commit 9472d86

Please sign in to comment.