Skip to content

Commit

Permalink
tmf: Fix a few SonarLint issues in TmfExperiment
Browse files Browse the repository at this point in the history
Fix a few SonarLint issues ([1,2] below) in TmfExperiment.

[1] Immediately return this expression instead of assigning it to the
temporary variable "context".

[2] Remove the "timeRange" field and declare it as a local variable in
the relevant methods.

Change-Id: Ifbabec0fb8a0b61c422e532f4ea53e88069b22c8
Signed-off-by: Marco Miller <marco.miller@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/201539
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 27, 2023
1 parent 658e72a commit 968ef61
Showing 1 changed file with 4 additions and 9 deletions.
Expand Up @@ -496,8 +496,7 @@ public synchronized ITmfContext seekEvent(final ITmfLocation location) {

@Override
public ITmfContext seekEvent(final double ratio) {
final ITmfContext context = seekEvent(Math.round(ratio * getNbEvents()));
return context;
return seekEvent(Math.round(ratio * getNbEvents()));
}

@Override
Expand Down Expand Up @@ -590,8 +589,7 @@ public ITmfLocation getCurrentLocation() {
@Override
public synchronized ITmfEvent parseEvent(final ITmfContext context) {
final ITmfContext tmpContext = seekEvent(context.getLocation());
final ITmfEvent event = getNext(tmpContext);
return event;
return getNext(tmpContext);
}

@Override
Expand Down Expand Up @@ -785,7 +783,6 @@ public void run() {
final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { //$NON-NLS-1$
private ITmfTimestamp safeTimestamp = null;
private ITmfTimestamp lastSafeTimestamp = null;
private TmfTimeRange timeRange = null;

@Override
public void run() {
Expand All @@ -802,12 +799,11 @@ public void run() {
endTimestamp = trace.getEndTime();
}
}
TmfTimeRange timeRange = null;
ITmfTimestamp safeTs = safeTimestamp;
if (safeTs != null && (lastSafeTimestamp == null || safeTs.compareTo(lastSafeTimestamp) > 0)) {
timeRange = new TmfTimeRange(startTimestamp, safeTs);
lastSafeTimestamp = safeTs;
} else {
timeRange = null;
}
safeTimestamp = endTimestamp;
if (timeRange != null) {
Expand Down Expand Up @@ -903,7 +899,6 @@ public ITmfLocation restoreLocation(ByteBuffer bufferIn) {
ranks[i] = bufferIn.getLong();
}
TmfLocationArray arr = new TmfLocationArray(locations, ranks);
TmfExperimentLocation l = new TmfExperimentLocation(arr);
return l;
return new TmfExperimentLocation(arr);
}
}

0 comments on commit 968ef61

Please sign in to comment.