Skip to content

Commit

Permalink
fixed issues reported by sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
azoitl authored and oberlehner committed Sep 3, 2024
1 parent 10871fa commit c0d2efe
Show file tree
Hide file tree
Showing 54 changed files with 766 additions and 587 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ protected void checkFordiacProject() {
excludePatterns = new ArrayList<>();
typelib = TypeLibraryManager.INSTANCE.getTypeLibrary(getFordiacProject());

library.getIncludes().getLibraryElement().forEach(elem -> {
includePatterns.add(createPattern(elem.getValue()));
});

library.getExcludes().getLibraryElement().forEach(elem -> {
excludePatterns.add(createPattern(elem.getValue()));
});
library.getIncludes().getLibraryElement().forEach(elem -> includePatterns.add(createPattern(elem.getValue())));
library.getExcludes().getLibraryElement().forEach(elem -> excludePatterns.add(createPattern(elem.getValue())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ public FBNetworkContextMenuProvider(final DiagramEditorWithFlyoutPalette editor,
this.typeLib = typeLib;
this.editor = editor;

editor.getViewer().getControl().addMenuDetectListener(e -> {
invocationLocation = getViewer().getControl().toControl(e.x, e.y);
});
editor.getViewer().getControl()
.addMenuDetectListener(e -> invocationLocation = getViewer().getControl().toControl(e.x, e.y));

}

Expand Down Expand Up @@ -133,8 +132,8 @@ public void buildContextMenu(final IMenuManager menu) {
menu.appendToGroup(GEFActionConstants.GROUP_COPY, action);

action = getRegistry().getAction(ActionFactory.PASTE.getId());
if (action instanceof PasteEditPartsAction) {
((PasteEditPartsAction) action).setPastRefPosition(getTranslatedAndZoomedPoint());
if (action instanceof final PasteEditPartsAction pasteAction) {
pasteAction.setPastRefPosition(getTranslatedAndZoomedPoint());
}
menu.appendToGroup(GEFActionConstants.GROUP_COPY, action);

Expand All @@ -153,10 +152,10 @@ public void buildFBInsertMenu(final IMenuManager menu, final Point point, final
private void fillMenuForFolder(final IMenuManager submenu, final IContainer container) {
try {
for (final IResource res : container.members()) {
if (res instanceof IFolder) {
createSubMenu(submenu, (IFolder) res);
} else if (res instanceof IFile) {
createFBMenuEntry(submenu, (IFile) res);
if (res instanceof final IFolder folder) {
createSubMenu(submenu, folder);
} else if (res instanceof final IFile file) {
createFBMenuEntry(submenu, file);
}
}
} catch (final CoreException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void validate() {
super.validate();
final Rectangle r = new Rectangle();
r.setBounds(getBounds());
r.crop(getInsets());
r.shrink(getInsets());
r.resize(-1, -1);
int size = Math.min(r.height, r.width);
size = Math.max(size, 1); // Size cannot be negative
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ public static EObject getEObjectFromEditor(final Object model) {
return getEObjectFromEditor(varDecl);
}

if (model instanceof final VarDeclaration varDecl
&& varDecl.getType() instanceof final ErrorMarkerDataType errorType) {
if (model instanceof final VarDeclaration varDecl && varDecl.getType() instanceof ErrorMarkerDataType) {
return varDecl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import org.eclipse.fordiac.ide.gef.policies.ModifiedNonResizeableEditPolicy;
import org.eclipse.fordiac.ide.model.commands.change.ChangeStructCommand;
import org.eclipse.fordiac.ide.model.data.StructuredType;
import org.eclipse.fordiac.ide.model.libraryElement.StructManipulator;
import org.eclipse.fordiac.ide.model.typelibrary.DataTypeEntry;
import org.eclipse.gef.EditPart;
Expand All @@ -37,15 +36,15 @@ protected Command getCreateCommand(final CreateRequest request) {
final Object childClass = request.getNewObjectType();
if ((getHost().getModel() instanceof final StructManipulator structManipulator)
&& (childClass instanceof final DataTypeEntry dataTypeEntry)) {
return new ChangeStructCommand(structManipulator, (StructuredType) dataTypeEntry.getType());
return new ChangeStructCommand(structManipulator, dataTypeEntry.getType());
}
}
return null;
}

@Override
protected Command getMoveChildrenCommand(final Request request) {
// TODO Auto-generated method stub
// children should not be moveable
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

public class ExpandedInterfacePositionMap {

private final static String PREFERENCE_STORE = "org.eclipse.fordiac.ide.gef"; //$NON-NLS-1$
private static final String PREFERENCE_STORE = "org.eclipse.fordiac.ide.gef"; //$NON-NLS-1$

private final SubAppForFBNetworkEditPart ep;
private Rectangle clientArea = null;
Expand Down Expand Up @@ -390,7 +390,7 @@ private Map<IFigure, Integer> calculateDirectPositions(final List<InterfaceEditP
.flatMap(Collection::stream)
.map(ConnectionEditPart.class::cast)
.filter(ExpandedInterfacePositionMap::isSkipConnection)
.collect(Collectors.toList());
.toList();
// @formatter:on

final var inputMap = new HashMap<IFigure, Integer>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.eclipse.osgi.util.NLS;

@SuppressWarnings("squid:S3008") // tell sonar the java naming convention does not make sense for this class
public class Messages extends NLS {
private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
public static String DeploymentFBEvaluator_InvalidEventCounter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public AdapterConnectionItemProviderEmfCompare(final AdapterFactory adapterFacto

@Override
public Collection<?> getChildren(final Object object) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Object getParent(final Object object) {

@Override
public Collection<?> getChildren(final Object object) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.eclipse.osgi.util.NLS;

@SuppressWarnings("squid:S3008") // tell sonar the java naming convention does not make sense for this class
public class Messages extends NLS {
private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
public static String XMIExportFilter_AttributeValueError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,55 +25,59 @@
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.fordiac.ide.fb.interpreter.design";
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.fordiac.ide.fb.interpreter.design"; //$NON-NLS-1$

// The shared instance
private static Activator plugin;
// The shared instance
private static Activator plugin;

private static Set<Viewpoint> viewpoints;
private static Set<Viewpoint> viewpoints;

/**
* The constructor
*/
public Activator() {
}
/**
* The constructor
*/
public Activator() {
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
viewpoints = new HashSet<Viewpoint>();
viewpoints.addAll(ViewpointRegistry.getInstance().registerFromPlugin(PLUGIN_ID + "/description/OpSem.odesign"));
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
* BundleContext)
*/
@Override
public void start(final BundleContext context) throws Exception {
super.start(context);
plugin = this;
viewpoints = new HashSet<>();
viewpoints.addAll(ViewpointRegistry.getInstance().registerFromPlugin(PLUGIN_ID + "/description/OpSem.odesign")); //$NON-NLS-1$
}

/*
* (non-Javadoc)
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
if (viewpoints != null) {
for (final Viewpoint viewpoint: viewpoints) {
ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
}
viewpoints.clear();
viewpoints = null;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(final BundleContext context) throws Exception {
plugin = null;
if (viewpoints != null) {
for (final Viewpoint viewpoint : viewpoints) {
ViewpointRegistry.getInstance().disposeFromPlugin(viewpoint);
}
viewpoints.clear();
viewpoints = null;
}
super.stop(context);
}
super.stop(context);
}

/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,14 @@ private static String sumParameter(final List<String> list) {
private static void setParameters(final FBTransaction transaction, final List<String> parameters) {
final List<VarDeclaration> paramVars = new ArrayList<>();
for (final String s : parameters) {
final VarDeclaration var = LibraryElementFactory.eINSTANCE.createVarDeclaration();
final VarDeclaration varDecl = LibraryElementFactory.eINSTANCE.createVarDeclaration();
final List<String> param = ServiceSequenceUtils.splitParameter(s);
if (param.size() == 2) {
var.setName(param.get(0));
var.setValue(LibraryElementFactory.eINSTANCE.createValue());
var.getValue().setValue(param.get(1));
varDecl.setName(param.get(0));
varDecl.setValue(LibraryElementFactory.eINSTANCE.createValue());
varDecl.getValue().setValue(param.get(1));
}
paramVars.add(var);
paramVars.add(varDecl);
}
transaction.getInputVariables().addAll(paramVars);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@
@SuppressWarnings("nls")
public final class CppBoostTestConstants {

static String newLine = System.getProperty("line.separator");
static final String NEW_LINE = System.getProperty("line.separator");

public static String testIncludeString = """
public static final String TEST_INCLUDE_STRING = """
#include "core/fbtests/fbtestfixture.h"
#include <forte_uint.h>
#include <forte_bool.h>\n""";
#include <forte_bool.h>""" + NEW_LINE;

public static String tester_genString = """
public static final String TESTER_GEN_STRING = """
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP
#include "{0}_ServiceSeq_gen.cpp"
#endif
""";

public static String testFixtureStruct = "struct {0}_TestFixture : public CFBTestFixtureBase '{'";
public static final String TEST_FIXTURE_STRUCT = "struct {0}_TestFixture : public CFBTestFixtureBase '{'";

public static String testFixtureBase = "{0}_TestFixture() : " + newLine
public static final String TEST_FICTURE_BASE = "{0}_TestFixture() : " + NEW_LINE
+ "CFBTestFixtureBase(g_nStringIdservSeq__{0}) '{'";

public static String testFixtureSetup = "CFBTestFixtureBase::setup();" + newLine + "}";
public static final String TEST_FICTURE_SETUP = "CFBTestFixtureBase::setup();" + NEW_LINE + "}";

public static String setInputDataSTART = "setInputData({";
public static String setInputDataEND = "});";
public static final String SET_INPUT_DATA_START = "setInputData({";
public static final String SET_INPUT_DATA_END = "});";

public static String setOutputDataSTART = "setOutputData({";
public static String setOutputDataEND = "});";
public static final String SET_OUTPUT_DATA_START = "setOutputData({";
public static final String SET_OUTPUT_DATA_END = "});";

public static String testSuiteName = "BOOST_FIXTURE_TEST_SUITE({0}TEST, {0}_TestFixture)";
public static String testSuiteEND = "BOOST_AUTO_TEST_SUITE_END()";
public static final String TEST_SUITE_NAME = "BOOST_FIXTURE_TEST_SUITE({0}TEST, {0}_TestFixture)";
public static final String TEST_SUITE_END = "BOOST_AUTO_TEST_SUITE_END()";

public static String testCase = "BOOST_AUTO_TEST_CASE({0}) '{'";
public static final String TEST_CASE = "BOOST_AUTO_TEST_CASE({0}) '{'";

public static String setECCState = "setECCState(CIEC_STATE({0}));";
public static final String SET_ECC_STATE = "setECCState(CIEC_STATE({0}));";

public static String triggerEvent = "triggerEvent({0});";
public static String triggerEventByID = "triggerEvent(CFBTestFixtureBase::getFB()->getEIID(CStringDictionary::getInstance().getId(\"{0}\")));";
public static final String TRIGGER_EVENT = "triggerEvent({0});";
public static final String TRIGGER_EVENT_BY_ID = "triggerEvent(CFBTestFixtureBase::getFB()->getEIID(CStringDictionary::getInstance().getId(\"{0}\")));";

public static String boostAssertEQUAL = "BOOST_TEST({0} == {1});";
public static String boostAssertNOTEQUAL = "BOOST_TEST({0} != {1});";
public static final String BOOS_ASSERT_EQUAL = "BOOST_TEST({0} == {1});";
public static final String BOOS_ASSERT_NOT_EQUAL = "BOOST_TEST({0} != {1});";

private CppBoostTestConstants() {
// empty private constructor
Expand Down
Loading

0 comments on commit c0d2efe

Please sign in to comment.