Skip to content

Commit

Permalink
tmf: Fix some SonarLint issues in TimeGraphControl
Browse files Browse the repository at this point in the history
Fix the few SonarLint issues [1,2,3] below in TimeGraphControl.

[1] Declare "endTime" on a separate line.
[2] Either remove or fill this block of code.
[3] Immediately return this expression instead of assigning it to the
temporary variable "x".

Change-Id: I8fc05b5cd92363ccb9fc5d9cf07e27522ac0d887
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/201570
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
  • Loading branch information
marco-miller committed Apr 28, 2023
1 parent 17e409b commit 3f5f296
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -596,7 +596,8 @@ public void removeDragSelectionListener(ITimeGraphTimeListener listener) {
*/
public void fireDragSelectionChanged(long start, long end) {
// check for backward intervals
long beginTime, endTime;
long beginTime;
long endTime;
if (start > end) {
beginTime = end;
endTime = start;
Expand Down Expand Up @@ -1774,8 +1775,7 @@ public int getXForTime(long time) {
int width = getSize().x;
int nameSpace = fTimeProvider.getNameSpace();
double pixelsPerNanoSec = (width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (width - nameSpace - RIGHT_MARGIN) / (time1 - time0);
int x = SaturatedArithmetic.add(getBounds().x + nameSpace, (int) ((time - time0) * pixelsPerNanoSec));
return x;
return SaturatedArithmetic.add(getBounds().x + nameSpace, (int) ((time - time0) * pixelsPerNanoSec));
}

@Override
Expand Down Expand Up @@ -3200,6 +3200,7 @@ private void updateCursor(int x, int stateMask) {
}
Cursor cursor = null;
if (fDragState == DRAG_SPLIT_LINE) {
// Nothing done.
} else if (fDragState == DRAG_SELECTION) {
cursor = fResizeCursor;
} else if (fDragState == DRAG_TRACE_ITEM) {
Expand Down

0 comments on commit 3f5f296

Please sign in to comment.