Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PMD Warnings AppendCharacterWithChar, LiteralsFirstInComparisons and
Browse files Browse the repository at this point in the history
UnusedAssignment
rubenporras committed Nov 10, 2023
1 parent ffe114c commit 81b4bb6
Showing 11 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@
import java.util.List;
import java.util.Set;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IPathVariableManager;
@@ -276,10 +276,10 @@ public boolean visit(final IResource resource) throws CoreException {
if (resource instanceof IProject) {
return true;
}
if (resource.getName().equals(META_INF)) {
if (META_INF.equals(resource.getName())) {
return true;
}
if (resource.getName().equals(MANIFEST_MF)) {
if (MANIFEST_MF.equals(resource.getName())) {
manifest.add(resource);
return false;
}
@@ -422,7 +422,7 @@ private static class DeployException extends Exception {
/** Constructor without cause exception. */
DeployException() {
}

/** Constructor with cause exception. */
DeployException(final Exception e) {
super(e);
Original file line number Diff line number Diff line change
@@ -345,7 +345,7 @@ private BufferedImage capture() {
private String captureCallStack() {
StringBuilder trace = new StringBuilder();
// Same info as on the screenshot
trace.append("TEST: ").append(testClassName).append(".").append(testMethodName).append(NEW_LINE);
trace.append("TEST: ").append(testClassName).append('.').append(testMethodName).append(NEW_LINE);
if (testStepStarted && currentTestStep != null && currentTestStepState != null) {
String colonWithSpace = ": ";
trace.append("TEST STEP: ").append(currentTestStep.getName()).append(colonWithSpace).append(currentTestStepState.toString()).append(NEW_LINE);
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ private boolean isEclipseShell(final SWTBotShell shell) {
* @return true, if is limbo shell
*/
private boolean isLimboShell(final SWTBotShell shell) {
return shell.getText().equals(LIMBO_SHELL);
return shell.getText().equals(LIMBO_SHELL); // NOPMD LiteralsFirstInComparisons
}

/**
@@ -154,7 +154,7 @@ private boolean isLimboShell(final SWTBotShell shell) {
* @return true, if is quick access shell
*/
private boolean isQuickAccess(final SWTBotShell shell) {
return shell.getText().equals(QUIK_ACCESS_SHELL);
return shell.getText().equals(QUIK_ACCESS_SHELL); // NOPMD LiteralsFirstInComparisons
}

private IWorkbenchWindow getActiveWorkbenchWindow() {
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ public static void waitUntilViewIsLoaded(final SWTBotView view) {
@Override
public boolean test() {
SWTBotTreeItem[] allItems = view.bot().tree().getAllItems();
return allItems.length == 0 || !allItems[0].getText().equals(LOADING_VIEW_MESSAGE);
return allItems.length == 0 || !LOADING_VIEW_MESSAGE.equals(allItems[0].getText());
}

@Override
@@ -48,6 +48,6 @@ public String getFailureMessage() {
/**
* Utility classes should have a private constructor.
*/
private SwtBotViewUtil() {}
private SwtBotViewUtil() {
}
}

Original file line number Diff line number Diff line change
@@ -57,8 +57,7 @@ public boolean hasCorrectExtension(final Delta delta, final IResourceServiceProv
* @return true if file belongs to the "src" directory
*/
public boolean isSourceOriginated(final Delta delta) {
return delta.getUri().segments().length > 2 && delta.getUri().segments()[2].trim().equalsIgnoreCase(GENERATION_FILE_SRC_DIRECTORY);
return delta.getUri().segments().length > 2 && GENERATION_FILE_SRC_DIRECTORY.equalsIgnoreCase(delta.getUri().segments()[2].trim());
}

}

Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@
import java.util.Map.Entry;
import java.util.Set;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
@@ -272,7 +272,7 @@ protected ImmutableList<IXtextBuilderParticipant> getCommonParticipants() {
*/
@Override
protected boolean readElement(final IConfigurationElement element, final boolean add) {
if (!element.getName().equals(PARTICIPANT)) {
if (!PARTICIPANT.equals(element.getName())) {
return false;
}
String className = element.getAttribute(ATT_CLASS);
Original file line number Diff line number Diff line change
@@ -247,7 +247,7 @@ private static Resource getGenModelResource(final EModelElement eModelElement) {
uri = uriConverter.normalize(uri);
uri = uri.trimFileExtension().appendFileExtension("genmodel"); //$NON-NLS-1$
uri = uriConverter.normalize(uri);
if (uri.scheme().equals("http")/* toString().equals(EcorePackage.eNS_URI) */) { //$NON-NLS-1$
if ("http".equals(uri.scheme())/* toString().equals(EcorePackage.eNS_URI) */) { //$NON-NLS-1$
return null; // optimization, because we are not interested in the extension for the Ecore model.
// otherwise getResource will go on the internet to load the model and we loose 20 seconds on each call!
}
Original file line number Diff line number Diff line change
@@ -852,7 +852,7 @@ protected EObject getCrossReferencedObject(final int sourceTag, final boolean tr
}
// We only handle references in assignments
Assignment assignment = EcoreUtil2.getContainerOfType(crossReference, Assignment.class);
EObject sourceObject = null;
EObject sourceObject;
String featureName = assignment.getFeature();
EReference reference = (EReference) context.eClass().getEStructuralFeature(featureName);
if (reference.isMany()) {
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ public ValidElement[] getTopLevelElements() {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
ArrayList<ValidElement> elements = new ArrayList<ValidElement>();
for (IConfigurationElement ce : configurationElements) {
if (ce.getName().equals(XML_TOP_ELEMENT_NAME)) {
if (XML_TOP_ELEMENT_NAME.equals(ce.getName())) {
ValidElement e = new ValidElement(ce);
elements.add(e);
}
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ public URI toPortableURI(final StorageAwareResource sourceResource, final URI ur

@Override
public EObject resolve(final StorageAwareResource resource, final String portableFragment) {
if (portableFragment.equals(UNRESOLVED_LAZY_LINK)) {
if (UNRESOLVED_LAZY_LINK.equals(portableFragment)) {
return null;
}
return super.resolve(resource, portableFragment);
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ public VirtualMachineTracer(final ITraceSet traceSet) {

@SuppressWarnings("nls")
public static boolean isHotSpotVM() {
return System.getProperty("java.vm.vendor").equals("Oracle Corporation") && System.getProperty("java.vm.name").indexOf("HotSpot") != -1;
return "Oracle Corporation".equals(System.getProperty("java.vm.vendor")) && System.getProperty("java.vm.name").indexOf("HotSpot") != -1;
}

/**
@@ -73,7 +73,7 @@ public void start() {
long vmStartTime = getApproximateNanoStartTime();

for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) {
Class<? extends TraceEvent> eventType = gcBean.getName().equals("ConcurrentMarkSweep") || gcBean.getName().equals("MarkSweepCompact") //$NON-NLS-1$ //$NON-NLS-2$
Class<? extends TraceEvent> eventType = "ConcurrentMarkSweep".equals(gcBean.getName()) || "MarkSweepCompact".equals(gcBean.getName()) //$NON-NLS-1$ //$NON-NLS-2$
? FullGarbageCollectionEvent.class
: MinorGarbageCollectionEvent.class;
NotificationEmitter emitter = (NotificationEmitter) gcBean;
@@ -83,7 +83,7 @@ public void start() {
public void handleNotification(final Notification notification, final Object handback) {
try {
// we only handle GARBAGE_COLLECTION_NOTIFICATION notifications here
if (notification.getType().equals("com.sun.management.gc.notification")) { //$NON-NLS-1$
if ("com.sun.management.gc.notification".equals(notification.getType())) { //$NON-NLS-1$
CompositeData cd = (CompositeData) notification.getUserData();
String gcAction = (String) cd.get("gcAction"); //$NON-NLS-1$
String gcCause = (String) cd.get("gcCause"); //$NON-NLS-1$

0 comments on commit 81b4bb6

Please sign in to comment.