From 7a16ca18f544850dabe45b7f4c78bce1587244a9 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Mon, 10 Aug 2015 16:42:35 -0400 Subject: [PATCH] Fix some trivial sonar warnings Change-Id: I3da053a5fb4186a8cbbef73f58dc50d8b89bbd8e --- .../gdb/launching/FinalLaunchSequence.java | 10 +++++---- .../cdt/dsf/gdb/launching/GdbLaunch.java | 9 ++++---- .../dsf/gdb/launching/GdbLaunchDelegate.java | 6 ++--- .../gdb/launching/InferiorRuntimeProcess.java | 1 + .../cdt/dsf/gdb/launching/LaunchUtils.java | 22 ++++++++++++------- .../gdb/launching/ServicesLaunchSequence.java | 12 +++++----- .../dsf/gdb/launching/ShutdownSequence.java | 7 +++--- 7 files changed, 39 insertions(+), 28 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java index 36a56920fbd..f6b1d83705f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2014 Ericsson and others. + * Copyright (c) 2008, 2015 Ericsson 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 @@ -174,8 +174,10 @@ public class FinalLaunchSequence extends ReflectionSequence { */ @RollBack("stepInitializeFinalLaunchSequence") public void rollBackInitializeFinalLaunchSequence(RequestMonitor requestMonitor) { - if (fTracker != null) fTracker.dispose(); - fTracker = null; + if (fTracker != null) { + fTracker.dispose(); + fTracker = null; + } requestMonitor.done(); } @@ -481,7 +483,7 @@ public class FinalLaunchSequence extends ReflectionSequence { sourceLookup.setSourceLookupPath(sourceLookupDmc, locator.getSourceContainers(), requestMonitor); } - private final static String INVALID = "invalid"; //$NON-NLS-1$ + private static final String INVALID = "invalid"; //$NON-NLS-1$ /** * If we are dealing with a remote-attach debugging session, connect to the target. * @since 4.0 diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index 97aba2e4ac1..6746a98c11f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2013 Wind River Systems and others. + * Copyright (c) 2006, 2015 Wind River Systems 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 @@ -195,7 +195,7 @@ public class GdbLaunch extends DsfLaunch // ITerminate static class LaunchCommandRequest extends CRequest implements IDebugCommandRequest { - Object[] elements; + private Object[] elements; public LaunchCommandRequest(Object[] objects) { elements = objects; @@ -323,8 +323,9 @@ public class GdbLaunch extends DsfLaunch // updating of some of the Debug view actions. // 'DebugEvent.TERMINATE' will be fired when each of the corresponding processes // exits and handled by 'handleDebugEvents()' method. - if (isTerminated()) + if (isTerminated()) { fireTerminate(); + } rm.setStatus(getStatus()); rm.done(); @@ -363,7 +364,7 @@ public class GdbLaunch extends DsfLaunch @Override public T getAdapter(Class adapter) { - if (adapter.equals(ITerminateHandler.class) == false) { + if (!adapter.equals(ITerminateHandler.class)) { // Must force adapters to be loaded. // Except in the case of terminate. Terminate can be used // when running headless (no UI) and therefore we should not diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java index dce6820febc..ed33f24bccf 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunchDelegate.java @@ -63,14 +63,14 @@ import org.eclipse.debug.core.model.ISourceLocator; @ThreadSafe public class GdbLaunchDelegate extends AbstractCLaunchDelegate2 { - public final static String GDB_DEBUG_MODEL_ID = "org.eclipse.cdt.dsf.gdb"; //$NON-NLS-1$ + public static final String GDB_DEBUG_MODEL_ID = "org.eclipse.cdt.dsf.gdb"; //$NON-NLS-1$ - private final static String NON_STOP_FIRST_VERSION = "6.8.50"; //$NON-NLS-1$ + private static final String NON_STOP_FIRST_VERSION = "6.8.50"; //$NON-NLS-1$ // Can be removed once we remove the deprecated newServiceFactory(String) private boolean fIsNonStopSession = false; - private final static String TRACING_FIRST_VERSION = "7.1.50"; //$NON-NLS-1$ + private static final String TRACING_FIRST_VERSION = "7.1.50"; //$NON-NLS-1$ private GdbLaunch fGdbLaunch; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/InferiorRuntimeProcess.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/InferiorRuntimeProcess.java index fabd877286c..88f95c7ced8 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/InferiorRuntimeProcess.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/InferiorRuntimeProcess.java @@ -74,6 +74,7 @@ public class InferiorRuntimeProcess extends RuntimeProcess { try { type = config.getType().getName(); } catch (CoreException e) { + type = null; } StringBuffer buffer = new StringBuffer(); buffer.append(config.getName()); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java index b0c9f6b578d..52ade05b7c6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/LaunchUtils.java @@ -449,39 +449,45 @@ public class LaunchUtils { return null; } IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - if (project == null || !project.isAccessible()) + if (project == null || !project.isAccessible()) { return null; + } ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project, false); // Not a CDT project? - if (projDesc == null) + if (projDesc == null) { return null; + } String buildConfigID = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); //$NON-NLS-1$ ICConfigurationDescription cfg = null; - if (buildConfigID.length() != 0) + if (buildConfigID.length() != 0) { cfg = projDesc.getConfigurationById(buildConfigID); + } // if configuration is null fall-back to active - if (cfg == null) + if (cfg == null) { cfg = projDesc.getActiveConfiguration(); + } // Environment variables and inherited vars HashMap envMap = new HashMap(); IEnvironmentVariable[] vars = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfg, true); - for (IEnvironmentVariable var : vars) + for (IEnvironmentVariable var : vars) { envMap.put(var.getName(), var.getValue()); + } // Add variables from build info - ICdtVariable[] build_vars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg); - for (ICdtVariable var : build_vars) { + ICdtVariable[] buildVars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg); + for (ICdtVariable var : buildVars) { try { // The project_classpath variable contributed by JDT is useless for running C/C++ // binaries, but it can be lethal if it has a very large value that exceeds shell // limit. See http://bugs.eclipse.org/bugs/show_bug.cgi?id=408522 - if (!"project_classpath".equals(var.getName())) //$NON-NLS-1$ + if (!"project_classpath".equals(var.getName())) {//$NON-NLS-1$ envMap.put(var.getName(), var.getStringValue()); + } } catch (CdtVariableException e) { // Some Eclipse dynamic variables can't be resolved dynamically... we don't care. } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java index aad97f33857..58b96107bf9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ServicesLaunchSequence.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 Wind River Systems and others. + * Copyright (c) 2006, 2015 Wind River Systems 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 @@ -40,13 +40,13 @@ import org.eclipse.core.runtime.IProgressMonitor; public class ServicesLaunchSequence extends Sequence { - DsfSession fSession; - GdbLaunch fLaunch; + private DsfSession fSession; + private GdbLaunch fLaunch; - ICommandControlService fCommandControl; - CSourceLookup fSourceLookup; + private ICommandControlService fCommandControl; + private CSourceLookup fSourceLookup; - Step[] fSteps = new Step[] { + private Step[] fSteps = new Step[] { new Step() { @Override public void execute(RequestMonitor requestMonitor) { fLaunch.getServiceFactory().createService(IMIBackend.class, fSession, fLaunch.getLaunchConfiguration()).initialize(requestMonitor); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java index b9cd1e30abb..0c6b3d49e4c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems and others. + * Copyright (c) 2006, 2015 Wind River Systems 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 @@ -27,7 +27,7 @@ public class ShutdownSequence extends Sequence { class ServiceShutdownStep extends Step { - IDsfService fService; + private IDsfService fService; ServiceShutdownStep( IDsfService service ) { super(); @@ -73,8 +73,9 @@ public class ShutdownSequence extends Sequence { private Step[] createSteps() { IDsfService[] services = getServices(); ServiceShutdownStep[] steps = new ServiceShutdownStep[services.length]; - for ( int i = 0; i < steps.length; ++i ) + for ( int i = 0; i < steps.length; ++i ) { steps[i] = new ServiceShutdownStep( services[i] ); + } return steps; }