Skip to content

Commit

Permalink
[cleanup] Fix a few Sonar issues
Browse files Browse the repository at this point in the history
Dead code, potential NPEs, inefficient iteration on keySet().

Change-Id: I8195120ffff6c8184698e824cdc0b59c228d0bd8
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
  • Loading branch information
pcdavid committed Feb 22, 2018
1 parent ab7a80c commit bc9b0d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2017 THALES GLOBAL SERVICES and others.
* Copyright (c) 2007, 2018 THALES GLOBAL SERVICES and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -457,7 +457,7 @@ private Command getReconnectTargetCommandAfterTool(ReconnectRequest request) {
if (cmdRouter != null) {
// The router has changed, therefore bendpoints are "reset" to only
// source and target
cmd = cmd == null ? cmdRouter : cmd.chain(cmdRouter);
cmd = cmd.chain(cmdRouter);
// reset the bendpoints
ConnectionAnchor sourceAnchor = node.getSourceConnectionAnchor(request);
PointList pointList = new PointList();
Expand All @@ -472,7 +472,7 @@ private Command getReconnectTargetCommandAfterTool(ReconnectRequest request) {
}
Command cmdBP = new ICommandProxy(sbbCommand);
if (cmdBP != null) {
cmd = cmd == null ? cmdBP : cmd.chain(cmdBP);
cmd = cmd.chain(cmdBP);
}
} else {
// The router is the same, therefore the bendpoint of the new
Expand Down Expand Up @@ -574,9 +574,7 @@ private void restoreMissingBendpointOverCandidate(ReconnectRequest request, Poin
}

// Addition of the missing bendpoint at the expected index
for (Integer index : pointToAddByIndexMap.keySet()) {
connectionPointList.insertPoint(pointToAddByIndexMap.get(index), index);
}
pointToAddByIndexMap.forEach((index, point) -> connectionPointList.insertPoint(point, index));
}

/**
Expand Down Expand Up @@ -1441,22 +1439,7 @@ private Diagram getDiagram(ConnectionEditPart connectionEditPart) {
* false otherwise
*/
private boolean isOrderedTreeLayoutOrCompositeLayout(Layout layout) {
boolean isLayout = false;
if (layout instanceof OrderedTreeLayout || layout instanceof CompositeLayout) {
if (layout instanceof CompositeLayout) {
// This code is commented because left to right run not
// correctly see ticket.
// CompositeLayout compositeLayout = (CompositeLayout) layout;
// if
// (!LayoutDirection.LEFT_TO_RIGHT.getLiteral().equals(compositeLayout.getDirection().getName()))
// {
isLayout = true;
// }
} else {
isLayout = true;
}
}
return isLayout;
return layout instanceof OrderedTreeLayout || layout instanceof CompositeLayout;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
* Copyright (c) 2002, 2016 IBM Corporation and others.
* Copyright (c) 2002, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -576,19 +576,17 @@ protected Command getResizeCommand(ChangeBoundsRequest request) {
ctc.add(setBoundsCommand);

// Compute the shift delta according to the real future bounds.
PrecisionPoint delta = new PrecisionPoint();
if (newBounds != null) {
PrecisionPoint delta = new PrecisionPoint();
if (getHost() instanceof IGraphicalEditPart) {
final Point parentOrigin = borderItemEP.getFigure().getParent().getBounds().getTopLeft();
Point parentOrigin = borderItemEP.getFigure().getParent().getBounds().getTopLeft();
Point oldRelativeBounds = borderItemEP.getFigure().getBounds().getTopLeft().translate(parentOrigin.getNegated());
delta = new PrecisionPoint(newBounds.getLocation().translate(oldRelativeBounds.getNegated()));
}
ShiftEdgeIdentityAnchorOperation operation = new ShiftEdgeIdentityAnchorOperation(request, newBounds.getSize(), delta);
ctc.add(CommandFactory.createICommand(editingDomain, operation));
}

ShiftEdgeIdentityAnchorOperation operation = new ShiftEdgeIdentityAnchorOperation(request, newBounds.getSize(), delta);
ICommand command = CommandFactory.createICommand(editingDomain, operation);
ctc.add(command);

// we add a command to keep the edges centered (if they should be)
CenterEditPartEdgesCommand centerEditPartEdgesCommand = new CenterEditPartEdgesCommand(borderItemEP, request);
ctc.add(centerEditPartEdgesCommand);
Expand Down

0 comments on commit bc9b0d4

Please sign in to comment.